Skip to content

Commit a1662c2

Browse files
Merge pull request #214 from jeromekelleher/try-tqdm-locks
Override tqdm's default locks
2 parents 9b03503 + 6926282 commit a1662c2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

bio2zarr/core.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@
2020

2121
numcodecs.blosc.use_threads = False
2222

23+
# By default Tqdm creates a multiprocessing Lock to synchronise across processes,
24+
# which seems to cause some problems with leaked semaphores on certain combinations
25+
# of Mac and Python versions. We only access tqdm from the main process though,
26+
# so we don't need it and can override with a simpler threading Lock.
27+
# NOTE: this gets set multiple times to different locks as subprocesses are
28+
# spawned, but it doesn't matter because the only tqdm instance that is
29+
# used is the one in the main process.
30+
tqdm.tqdm.set_lock(threading.RLock())
31+
2332

2433
def display_number(x):
2534
ret = "n/a"
@@ -248,7 +257,6 @@ def __init__(self, worker_processes=1, progress_config=None):
248257
def _update_progress(self):
249258
current = get_progress()
250259
inc = current - self.progress_bar.n
251-
# print("UPDATE PROGRESS: current = ", current, self.progress_config.total, inc)
252260
self.progress_bar.update(inc)
253261

254262
def _update_progress_worker(self):

0 commit comments

Comments
 (0)