Skip to content

Commit

Permalink
Override tqdm's default locks
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromekelleher committed May 15, 2024
1 parent 9b03503 commit 0542602
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bio2zarr/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@

numcodecs.blosc.use_threads = False

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


def display_number(x):
ret = "n/a"
Expand Down Expand Up @@ -248,7 +257,6 @@ def __init__(self, worker_processes=1, progress_config=None):
def _update_progress(self):
current = get_progress()
inc = current - self.progress_bar.n
# print("UPDATE PROGRESS: current = ", current, self.progress_config.total, inc)
self.progress_bar.update(inc)

def _update_progress_worker(self):
Expand Down

0 comments on commit 0542602

Please sign in to comment.