MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _executor_map

Function _executor_map

pager_lib/tqdm/contrib/concurrent.py:29–51  ·  view source on GitHub ↗

Implementation of `thread_map` and `process_map`. Parameters ---------- tqdm_class : [default: tqdm.auto.tqdm]. max_workers : [default: min(32, cpu_count() + 4)]. chunksize : [default: 1]. lock_name : [default: "":str].

(PoolExecutor, fn, *iterables, **tqdm_kwargs)

Source from the content-addressed store, hash-verified

27
28
29def _executor_map(PoolExecutor, fn, *iterables, **tqdm_kwargs):
30 """
31 Implementation of `thread_map` and `process_map`.
32
33 Parameters
34 ----------
35 tqdm_class : [default: tqdm.auto.tqdm].
36 max_workers : [default: min(32, cpu_count() + 4)].
37 chunksize : [default: 1].
38 lock_name : [default: "":str].
39 """
40 kwargs = tqdm_kwargs.copy()
41 if "total" not in kwargs:
42 kwargs["total"] = length_hint(iterables[0])
43 tqdm_class = kwargs.pop("tqdm_class", tqdm_auto)
44 max_workers = kwargs.pop("max_workers", min(32, cpu_count() + 4))
45 chunksize = kwargs.pop("chunksize", 1)
46 lock_name = kwargs.pop("lock_name", "")
47 with ensure_lock(tqdm_class, lock_name=lock_name) as lk:
48 # share lock in case workers are already using `tqdm`
49 with PoolExecutor(max_workers=max_workers, initializer=tqdm_class.set_lock,
50 initargs=(lk,)) as ex:
51 return list(tqdm_class(ex.map(fn, *iterables, chunksize=chunksize), **kwargs))
52
53
54def thread_map(fn, *iterables, **tqdm_kwargs):

Callers 2

thread_mapFunction · 0.85
process_mapFunction · 0.85

Calls 3

ensure_lockFunction · 0.85
copyMethod · 0.80
popMethod · 0.80

Tested by

no test coverage detected