tornadoweb / tornadoweb/tornado

Uncaught exception - After upgrading python version

Open
#2,836 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi,

I'm using Tornado 5.1.1
Recently I upgraded my python from 2.7.15 to 3.6.8.

Yesterday I got a strange exceptions for a few seconds (tons of that):

2020-04-04 21:04:39.153 ERROR [4592 140100505929536 tornado.general] Uncaught exception
Traceback (most recent call last):
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/http1connection.py", line 735, in _server_request_loop
    ret = yield conn.read_response(request_delegate)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/http1connection.py", line 245, in _read_message
    self.stream.set_close_callback(self._on_connection_close)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 606, in set_close_callback
    self._maybe_add_error_listener()
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 1128, in _maybe_add_error_listener
    self._add_io_state(ioloop.IOLoop.READ)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 1158, in _add_io_state
    self.fileno(), self._handle_events, self._state)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/platform/asyncio.py", line 76, in add_handler
    raise ValueError("fd %s added twice" % fd)
ValueError: fd 65 added twice
2020-04-04 21:04:39.417 ERROR [4118 140423800596288 tornado.general] Uncaught exception
Traceback (most recent call last):
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/http1connection.py", line 735, in _server_request_loop
    ret = yield conn.read_response(request_delegate)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1133, in run
    value = future.result()
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/http1connection.py", line 245, in _read_message
    self.stream.set_close_callback(self._on_connection_close)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 606, in set_close_callback
    self._maybe_add_error_listener()
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 1128, in _maybe_add_error_listener
    self._add_io_state(ioloop.IOLoop.READ)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/iostream.py", line 1158, in _add_io_state
    self.fileno(), self._handle_events, self._state)
  File "/srv/dy/rcomserver/venv/lib64/python3.6/site-packages/tornado/platform/asyncio.py", line 76, in add_handler
    raise ValueError("fd %s added twice" % fd)
ValueError: fd 63 added twice

Any idea why it happened? or how to debug/reproduce? not sure if related to my upgrade or not but I never saw that before..

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 with the traceback locations in tornado/http1connection.py, tornado/iostream.py, and tornado/platform/asyncio.py, then inspect how file descriptors are registered during the server request loop. Try to reproduce the duplicate fd registration across the reported Python versions. Done means identifying the cause and capturing the behavior in a regression test or clearly documenting why it cannot be reproduced.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 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.