cleverly.learners.thread_limit#

cleverly.learners.thread_limit(limit: int | None = -1) → Iterator[None][source]#

Limit native thread pools for the duration of the block.

Parameters:
limitint or None

Threads per fit inside the block. -1 (the default) means “use the configured default”; pass an explicit value to override it for one call.

Yields:
None

The block runs with the limit applied, and the previous limit is restored on exit.

Notes

The controller doing the limiting is process-wide and built once. See the module docstring for why, for what refcounting the blocks buys when two of them overlap, and refresh_thread_pools() for when the cache has to be discarded.