def threaded_io(vs, filepath, mode):
"""
If using IO threads, start a new thread to write the netCDF data to disk.
"""
if vs.use_io_threads:
_wait_for_disk(vs, filepath)
_io_locks[filepath].clear()
nc_dataset = Dataset(filepath, mode)
try:
yield nc_dataset
finally:
if vs.use_io_threads:
io_thread = threading.Thread(target=_write_to_disk, args=(vs, nc_dataset, filepath))
io_thread.start()
else:
_write_to_disk(vs, nc_dataset, filepath)
评论列表
文章目录