gevent.py 文件源码

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

项目:easypy 作者: weka-io 项目源码 文件源码
def _patch_module_locks():
    # gevent will not patch existing locks (including ModuleLocks) when it's not single threaded
    # our solution is to monkey patch the release method for ModuleLocks objects
    # we assume that patching is done early enough so no other locks are present

    import importlib
    _old_release = importlib._bootstrap._ModuleLock.release

    def _release(*args, **kw):
        lock = args[0]
        if lock.owner == main_thread_ident_before_patching:
            lock.owner = threading.main_thread().ident
        _old_release(*args, **kw)

    importlib._bootstrap._ModuleLock.release = _release
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号