Skip to content

ConnectionResetError when close browser, but not all static files was fetch #1773

Closed
@AlexanderMartynoff

Description

While receive a large static file, if you break the connection, an exception throws:

  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 429, in start
    Yield from resp.prepare (request)
  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 232, in prepare
    Return (yield from self._sendfile (request, fobj, count))
  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 120, in _sendfile_system
    Yield from writer.sendfile (fobj, count)
  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 74, in sendfile
    Yield from fut
  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 40, in _sendfile_cb
    N = os.sendfile (out_fd, in_fd, offset, count)
ConnectionResetError: [Errno 104] Connection reset by peer

In the future, when you try to get a large file, an exception throws:

RuntimeError: File descriptor 13 is used by transport <_SelectorSocketTransport fd = 13 read = polling write = <polling, bufsize = 0 >>
Exception in callback SendfilePayloadWriter._sendfile_cb (, 13, 12, 4606528, 9040240, <_UnixSelecto ... e debug = False>, True)
Handle: <Handle SendfilePayloadWriter._sendfile_cb (, 13, 12, 4606528, 9040240, <_UnixSelecto ... e debug = False>, True)>
Traceback (most recent last call last):
  File "/home/user/.virtualenvs/local/lib/python3.6/asyncio/events.py", line 126, in _run
    Self._callback (* self._args)
  File "/home/user/.virtualenvs/local/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 36, in _sendfile_cb
    Loop.remove_writer (out_fd)
  File "/home/user/.virtualenvs/local/lib/python3.6/asyncio/selector_events.py", line 351, in remove_writer
    Self._ensure_fd_no_transport (fd)
  File "/home/user/.virtualenvs/local/lib/python3.6/asyncio/selector_events.py", line 258, in _ensure_fd_no_transport
    Fd, transport))

Python: 3.6
aiohttp 2.0.5
File size: > 16 mb

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions