Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override tqdm's default locks #214

Merged
merged 1 commit into from
May 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 synchronise 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
Loading