Skip to content

tqdm.contrib.concurrent#

Thin wrappers around concurrent.futures.

ensure_lock#

[view source]

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

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

  • tqdm_class: optional
    tqdm class to use for bars [default: tqdm.auto.tqdm].
  • max_workers: int, optional
    Maximum number of workers to spawn; passed to concurrent.futures.ThreadPoolExecutor.__init__. [default: max(32, cpu_count() + 4)].

process_map#

[view source]

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 to concurrent.futures.ProcessPoolExecutor.__init__. [default: min(32, cpu_count() + 4)].
  • chunksize: int, optional
    Size of chunks sent to worker processes; passed to concurrent.futures.ProcessPoolExecutor.map. [default: 1].
  • lock_name: str, optional
    Member of tqdm_class.get_lock() to use [default: mp_lock].