tornadoweb / tornadoweb/tornado

simple_httpclient: Timeout after redirect not raised properly

Open
#3,064 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

httpclient
Dominant language
Python
Stars
22.2k
Forks
5.6k
Avg merge
3h 42m
Merged PRs (30d)
16

Description

Hello,
My test codes are below:

import traceback
from tornado import httpclient

def test():
client = httpclient.HTTPClient()
url = "http://www.baidu.com/link?url=7rwodBCaetm-ogDMm0fCdkj-Crje0M21LIWnXbz3XxToow8VmZwXOZaEz1nBMJBKofatc2X8SlFXyNvv5D7HhWgpIB8MDi5R85IYL30OjDmW4URWPW5y4AIwkVKioJSxPPBzWJmmaO11fEEO__BLxIiiT1FcKw8asqqF7h1QupS"
try:
response = client.fetch(url)
print(response)
except:
traceback.print_exc()

if name == "main":
test()

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

How to fix it?
Thanks!

Python 3.8.5
Tornado 6.1

Try to run it several times to get above error

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the redirect timeout with HTTPClient.fetch and the URL from the report. Then inspect simple_httpclient.py around line 664, where the stack trace shows the callback failure. Done means a timeout after a redirect raises cleanly without leaving the client suspended.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.