Skip to content

Commit

Permalink
Optional lock with no multiprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaRenauld committed Jul 13, 2023
1 parent d737eaf commit b895ddd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scilpy/tracking/tracker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from contextlib import nullcontext
import itertools
import logging
import multiprocessing
Expand Down Expand Up @@ -265,7 +266,7 @@ def _reload_data_for_new_process(self, init_args):
self.propagator.reset_data(np.load(
init_args['data_file_name'], mmap_mode=init_args['mmap_mode']))

def _get_streamlines(self, chunk_id, lock):
def _get_streamlines(self, chunk_id, lock=None):
"""
Tracks the n streamlines associates with current process (identified by
chunk_id). The number n is the total number of seeds / the number of
Expand All @@ -277,7 +278,8 @@ def _get_streamlines(self, chunk_id, lock):
chunk_id: int
This process ID.
lock: Lock
The multiprocessing lock
The multiprocessing lock for verbose printing (optional with
single processing).
Returns
-------
Expand All @@ -303,6 +305,8 @@ def _get_streamlines(self, chunk_id, lock):
tqdm_text = "#" + "{}".format(chunk_id).zfill(3)

if self.verbose:
if lock is None:
lock = nullcontext()
with lock:
# Note. Option miniters does not work with manual pbar update.
# Will verify manually, lower.
Expand Down

0 comments on commit b895ddd

Please sign in to comment.