MCPcopy Create free account
hub / github.com/dask/dask / warm_up_thread_pool

Function warm_up_thread_pool

dask/tests/test_threaded.py:205–219  ·  view source on GitHub ↗

Ensure that there is a warm thread pool. With num_workers=None on the default thread, this function warms up the default thread pool. With num_workers set or from a different thread, this function spawns and warms up a non-default thread pool. When this function is called after ano

(num_workers: int | None)

Source from the content-addressed store, hash-verified

203
204
205def warm_up_thread_pool(num_workers: int | None) -> None:
206 """Ensure that there is a warm thread pool.
207
208 With num_workers=None on the default thread, this function warms up the default
209 thread pool. With num_workers set or from a different thread, this function spawns
210 and warms up a non-default thread pool.
211
212 When this function is called after another test that called get() or compute(), the
213 thread pool will be already warm, at least partially (not all threads will
214 necessarily be already running).
215 """
216 parties = num_workers or CPU_COUNT
217 barrier = threading.Barrier(parties)
218 dsk = {("x", i): (barrier.wait,) for i in range(parties)}
219 get(dsk, list(dsk), num_workers=num_workers)
220
221
222test_ctxvar = contextvars.ContextVar("test_ctxvar", default=42)

Callers 2

test_contextvarsFunction · 0.85

Calls 1

getFunction · 0.90

Tested by

no test coverage detected