handler_test.py 文件源码

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

项目:PowerSpikeGG 作者: PowerSpikeGG 项目源码 文件源码
def test_multi_thread(self):
        """Try to send requests in a multi-threaded context."""
        client = LocalRiotAPIHandler("some random token",
            limits=[RateLimiter(2, 0.5)])
        client.server_address = "%s:%s" % self.server_address

        def run():
            client.get_match(4242)

        threads = [threading.Thread(target=run) for _ in range(2)]
        start = time.time()
        for thread in threads:
            thread.start()
        for thread in threads:
            thread.join()
        self.assertLess(time.time() - start, 0.5)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号