コード例 #1
0
 def test_global_limit_rate(self):
     aiothrottle.limit_rate(10)
     klass = ClientResponse.flow_control_class
     self.assertIsInstance(klass, functools.partial)
     r = klass(self.stream, loop=self.loop)
     self.assertIsInstance(r, aiothrottle.ThrottledStreamReader)
     self.assertEqual(r._throttle.limit, 10)
コード例 #2
0
def main():
    # setup the rate limit to 200 KB/s
    aiothrottle.limit_rate(200 * 1024)

    # download a large file without blocking bandwidth
    loop = asyncio.get_event_loop()
    loop.run_until_complete(load_file(
        "http://ipv4.download.thinkbroadband.com/10MB.zip", loop))

    # unset the rate limit
    aiothrottle.unlimit_rate()
コード例 #3
0
 def test_global_unlimit_rate(self):
     aiothrottle.limit_rate(10)
     aiothrottle.unlimit_rate()
     klass = ClientResponse.flow_control_class
     self.assertIs(klass, aiohttp.streams.FlowControlStreamReader)