def current_default_worker_thread_limiter():
"""Get the default :class:`CapacityLimiter` used by
:func:`run_sync_in_worker_thread`.
The most common reason to call this would be if you want to modify its
:attr:`~CapacityLimiter.total_tokens` attribute.
"""
try:
limiter = _limiter_local.limiter
except AttributeError:
limiter = _limiter_local.limiter = CapacityLimiter(DEFAULT_LIMIT)
return limiter
# Eventually we might build this into a full-fledged deadlock-detection
# system; see https://github.com/python-trio/trio/issues/182
# But for now we just need an object to stand in for the thread, so we can
# keep track of who's holding the CapacityLimiter's token.
评论列表
文章目录