tqdm.contrib.concurrent#
Thin wrappers around concurrent.futures
.
ensure_lock#
@contextmanager
def ensure_lock(tqdm_class, lock_name="")
get (create if necessary) and then restore tqdm_class
's lock
thread_map#
def thread_map(fn, *iterables, **tqdm_kwargs)
Equivalent of list(map(fn, *iterables))
driven by concurrent.futures.ThreadPoolExecutor
.
Parameters
- tqdm_class: optional
tqdm
class to use for bars [default: tqdm.auto.tqdm]. - max_workers: int, optional
Maximum number of workers to spawn; passed toconcurrent.futures.ThreadPoolExecutor.__init__
. [default: max(32, cpu_count() + 4)].
process_map#
def process_map(fn, *iterables, **tqdm_kwargs)
Equivalent of list(map(fn, *iterables))
driven by concurrent.futures.ProcessPoolExecutor
.
Parameters
- tqdm_class: optional
tqdm
class to use for bars [default: tqdm.auto.tqdm]. - max_workers: int, optional
Maximum number of workers to spawn; passed toconcurrent.futures.ProcessPoolExecutor.__init__
. [default: min(32, cpu_count() + 4)]. - chunksize: int, optional
Size of chunks sent to worker processes; passed toconcurrent.futures.ProcessPoolExecutor.map
. [default: 1]. - lock_name: str, optional
Member oftqdm_class.get_lock()
to use [default: mp_lock].