You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
simple_httpclient: Timeout after redirect not raised properly #3064
It is suspended after got tornado.simple_httpclient.HTTPTimeoutError. The stack trace is
ERROR:asyncio:Exception in callback _HTTPConnection.finish..() at /home/python3/.miniconda3/lib/python3.8/site-packages/tornado/simple_httpclient.py:664
handle: <Handle _HTTPConnection.finish..() at /home/python3/.miniconda3/lib/python3.8/site-packages/tornado/simple_httpclient.py:664>
Traceback (most recent call last):
File "/home/python3/.miniconda3/lib/python3.8/asyncio/events.py", line 81, in _run
self._context.run(self._callback, *self._args)
File "/home/python3/.miniconda3/lib/python3.8/site-packages/tornado/simple_httpclient.py", line 664, in
fut.add_done_callback(lambda f: final_callback(f.result()))
tornado.simple_httpclient.HTTPTimeoutError: Timeout during request
This looks like a bug when following redirects: some errors from the second request aren't getting raised correctly. This probably affects asynchronous usage as well as the synchronous HTTPClient, although I'm not certain. There are a couple of workarounds:
Install pycurl and run AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient") at the start of your program
Pass follow_redirects=False to fetch and handle the redirect yourself.
The two known workarounds are the ones mentioned in my previous comment. If you can't use pycurl, you can pass follow_redirects=False and handle the redirects yourself, although this is a little more code on your side.
You might also be able to use something like tornado.gen.with_timeout and get timeouts there instead of from the http client itself, although I haven't tried this and I'm not sure if it would clean up all resources correctly.
The two known workarounds are the ones mentioned in my previous comment. If you can't use pycurl, you can pass follow_redirects=False and handle the redirects yourself, although this is a little more code on your side.
You might also be able to use something like tornado.gen.with_timeout and get timeouts there instead of from the http client itself, although I haven't tried this and I'm not sure if it would clean up all resources correctly.
Activity
Python-37 commentedon Sep 18, 2021
Did you try to open the URL in your web browser?
[-]App hang after got HTTPTimeoutError[/-][+]simple_httpclient: Timeout after redirect not raised properly[/+]bdarnell commentedon Sep 18, 2021
This looks like a bug when following redirects: some errors from the second request aren't getting raised correctly. This probably affects asynchronous usage as well as the synchronous HTTPClient, although I'm not certain. There are a couple of workarounds:
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")at the start of your programfollow_redirects=Falsetofetchand handle the redirect yourself.wxy8wxy commentedon Sep 18, 2021
AsyncHTTPClient also has the same error. The CurlAsyncHTTPClient works
Thanks!
kindernerd commentedon Apr 25, 2025
is there a solution without CurlAsyncHTTPClient? stuck in the same situation
bdarnell commentedon Apr 25, 2025
The two known workarounds are the ones mentioned in my previous comment. If you can't use pycurl, you can pass
follow_redirects=Falseand handle the redirects yourself, although this is a little more code on your side.You might also be able to use something like
tornado.gen.with_timeoutand get timeouts there instead of from the http client itself, although I haven't tried this and I'm not sure if it would clean up all resources correctly.kindernerd commentedon Apr 25, 2025
Thx for the very detailed explanation
bdarnell commentedon Nov 13, 2026
This was fixed in Tornado 6.6.1 and in PR #3878 for the master branch.
Fix redirect timeout propagation
httpclient_test: Test connection errors while following a redirect