tqdm.contrib.concurrent#
Thin wrappers around concurrent.futures.
ensure_lock#
@contextmanager
def ensure_lock(tqdm_class, lock_name="", lock=None)
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
- max_workers: int, optional
Maximum number of workers to spawn; passed toconcurrent.futures.ThreadPoolExecutor. - thread_name_prefix: str, optional
Passed toconcurrent.futures.ThreadPoolExecutor[default: '']. - timeout: int or float, optional
Seconds to wait before raisingTimeoutErrorif__next__is called and the result isn't available. [default: None]. - buffersize: int, optional
Requires Python>=3.14 [default: None]. - tqdm_class: optional
tqdmclass to use for bars [default: tqdm.auto.tqdm]. - smoothing: float, optional
Passed totqdm_class; the [default: 0] is average (due to erratic update frequency). - lock_name: str, optional
Member oftqdm_class.get_lock()to use [default: ''].
interpreter_map#
def interpreter_map(fn, *iterables, **tqdm_kwargs)
Equivalent of list(map(fn, *iterables)) driven by concurrent.futures.InterpreterPoolExecutor (Python 3.14+).
Parameters
Same as thread_map.
Notes
fn, its arguments, and its return values must be pickleable. Worker progress bars using the same tqdm_class share a cross-interpreter write lock.
process_map#
def process_map(fn, *iterables, lock_name="mp_lock", **tqdm_kwargs)
Equivalent of list(map(fn, *iterables)) driven by concurrent.futures.ProcessPoolExecutor.
Parameters
- max_workers: int, optional
Maximum number of workers to spawn; passed toconcurrent.futures.ProcessPoolExecutor. - timeout: int or float, optional
Seconds to wait before raisingTimeoutErrorif__next__is called and the result isn't available. [default: None]. - chunksize: int, optional
Approximate size of chunks sent to worker processes; passed toconcurrent.futures.ProcessPoolExecutor.map. [default: 1]. - buffersize: int, optional
Requires Python>=3.14 [default: None]. - max_tasks_per_child: int, optional
Maximum number of tasks a worker process can complete before being replaced with a new process; passed toconcurrent.futures.ProcessPoolExecutor. - mp_context: multiprocessing.BaseContext, optional
Multiprocessing context to use, e.g.multiprocessing.get_context('fork'). - lock_name: str, optional
Member oftqdm_class.get_lock()to use [default: mp_lock]. - tqdm_class: optional
tqdmclass to use for bars [default: tqdm.auto.tqdm]. - smoothing: float, optional
Passed totqdm_class; the [default: 0] is average (due to erratic update frequency).