Skip to content

StreamClosedError exception at closing connection (maybe an error from my side) #11

@elieLeE

Description

@elieLeE

Hello @bdarnell,

tanks for the project.

I have an issue at the end on a request. On a the server part, when I write something and then call finish method, I have the exception:

ERROR:tornado.application:Exception in callback functools.partial(<function wrap.<locals>.null_wrapper at 0x7f557008da60>, <Future finished result=None>)
Traceback (most recent call last):
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado/ioloop.py", line 759, in _run_callback
    ret = callback()
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado/stack_context.py", line 300, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado_http2/stream.py", line 226, in <lambda>
    future, lambda f: self._send_window_update(len(frame.data)))
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado_http2/stream.py", line 232, in _send_window_update
    self.conn._write_frame(Frame(
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado_http2/connection.py", line 193, in _write_frame
    return self.stream.write(encoded_frame)
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado/iostream.py", line 574, in write
    self._check_closed()
  File "/home/elie/.cache/pypoetry/virtualenvs/mmsx-lOcQDb_O-py3.9/lib/python3.9/site-packages/tornado/iostream.py", line 1119, in _check_closed
    raise StreamClosedError(err)
tornado.iostream.StreamClosedError: Stream is closed

I think it is beacuse when the write is done, a Future is created here:

  if frame.data and self._delegate_started:
       future = self.delegate.data_received(frame.data)
       if future is None:
            self._send_window_update(len(frame.data))
        else:
            IOLoop.current().add_future(
                future, lambda f: self._send_window_update(len(frame.data)))

in _handle_data_frame in stream.py file.

So, when I close the connection, the write is on going and I have the exception.

I have tried to wait the write without sucess. Maybe, it is an error of my part but I did not succeed what is the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions