_threads.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:trio 作者: python-trio 项目源码 文件源码
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.
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号