test_loopback.py 文件源码

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

项目:zenchmarks 作者: squeaky-pl 项目源码 文件源码
def test_pullProducer(self):
        """
        Test a pull producer registered against a loopback transport.
        """
        @implementer(IPullProducer)
        class PullProducer(object):
            def __init__(self, toProduce):
                self.toProduce = toProduce

            def start(self, consumer):
                self.consumer = consumer
                self.consumer.registerProducer(self, False)

            def resumeProducing(self):
                self.consumer.write(self.toProduce.pop(0))
                if not self.toProduce:
                    self.consumer.unregisterProducer()
        return self._producertest(PullProducer)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号