ZRendezvous.py 文件源码

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

项目:ZServer 作者: zopefoundation 项目源码 文件源码
def __init__(self, n=1):
        sync = thread.allocate_lock()
        self._acquire = sync.acquire
        self._release = sync.release
        pool = []
        self._lists = (
            pool,  # Collection of locks representing threads are not
                   # waiting for work to do
            [],    # Request queue
            [],    # Pool of locks representing threads that are
                   # waiting (ready) for work to do.
        )

        self._acquire()  # callers will block
        try:
            while n > 0:
                l = thread.allocate_lock()
                l.acquire()
                pool.append(l)
                thread.start_new_thread(ZServerPublisher,
                                        (self.accept,))
                n = n - 1
        finally:
            self._release()  # let callers through now
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号