Skip to content

tqdm.contrib.concurrent#

Thin wrappers around concurrent.futures.

ensure_lock#

[view source]

@contextmanager
def ensure_lock(tqdm_class, lock_name="", lock=None)

get (create if necessary) and then restore tqdm_class's lock

thread_map#

[view source]

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 to concurrent.futures.ThreadPoolExecutor.
  • thread_name_prefix: str, optional
    Passed to concurrent.futures.ThreadPoolExecutor [default: ''].
  • timeout: int or float, optional
    Seconds to wait before raising TimeoutError if __next__ is called and the result isn't available. [default: None].
  • buffersize: int, optional
    Requires Python>=3.14 [default: None].
  • tqdm_class: optional
    tqdm class to use for bars [default: tqdm.auto.tqdm].
  • smoothing: float, optional
    Passed to tqdm_class; the [default: 0] is average (due to erratic update frequency).
  • lock_name: str, optional
    Member of tqdm_class.get_lock() to use [default: ''].

interpreter_map#

[view source]

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#

[view source]

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 to concurrent.futures.ProcessPoolExecutor.
  • timeout: int or float, optional
    Seconds to wait before raising TimeoutError if __next__ is called and the result isn't available. [default: None].
  • chunksize: int, optional
    Approximate size of chunks sent to worker processes; passed to concurrent.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 to concurrent.futures.ProcessPoolExecutor.
  • mp_context: multiprocessing.BaseContext, optional
    Multiprocessing context to use, e.g. multiprocessing.get_context('fork').
  • lock_name: str, optional
    Member of tqdm_class.get_lock() to use [default: mp_lock].
  • tqdm_class: optional
    tqdm class to use for bars [default: tqdm.auto.tqdm].
  • smoothing: float, optional
    Passed to tqdm_class; the [default: 0] is average (due to erratic update frequency).