Created
November 22, 2015 16:48
-
-
Save mvschaik/fc66f14fb903dc2f0454 to your computer and use it in GitHub Desktop.
Testing timeouts of AsyncHTTPClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Code: 599 | |
Req time: 2.00384807587 | |
Timing info | |
{} | |
-------------------- | |
Code: 599 | |
Req time: 5.00563097 | |
Timing info | |
{} | |
-------------------- | |
Code: 200 | |
Req time: 1.54284501076 | |
Timing info | |
{'connect': 0.105714, | |
'namelookup': 4e-05, | |
'pretransfer': 0.238591, | |
'queue': 5.0056469440460205, | |
'redirect': 0.0, | |
'starttransfer': 1.5395889999999999, | |
'total': 1.540745} | |
-------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tornado.httpclient import AsyncHTTPClient | |
from tornado.ioloop import IOLoop | |
from pprint import pprint | |
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient") | |
def completed(resp): | |
print("Code: %s" % resp.code) | |
print("Req time: %s" % resp.request_time) | |
print("Timing info") | |
pprint(resp.time_info) | |
print("-" * 20) | |
def main(): | |
client = AsyncHTTPClient(max_clients=1, defaults=dict(request_timeout=2.0)) | |
client.fetch('https://httpbin.org/delay/3', callback=completed) | |
client.fetch('https://httpbin.org/delay/3', callback=completed) | |
client.fetch('https://httpbin.org/delay/1', callback=completed) | |
IOLoop.current().start() | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment