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

Function warm_up_thread_pool

dask/tests/test_threaded.py:197–211  ·  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

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

Callers 2

test_contextvarsFunction · 0.85

Calls 1

getFunction · 0.90

Tested by

no test coverage detected