aio-libs / aiohttp

Asynchronous HTTP client/server framework for asyncio and Python
https://docs.aiohttp.org
Other
14.98k stars 2k forks source link

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

Open AlexanderMartynoff opened 7 years ago

AlexanderMartynoff commented 7 years ago

1773 - The problem still remains in ver. 2.1.0.dev0:

RuntimeError: File descriptor 12 is used by transport <_SelectorSocketTransport fd=12 read=polling write=<polling, bufsize=0>>
Exception in callback SendfilePayloadWriter._sendfile_cb(<Future cance...events.py:275>, 12, 9, 30240, 1018100, <_UnixSelecto...se debug=True>, True)
handle: <Handle SendfilePayloadWriter._sendfile_cb(<Future cance...events.py:275>, 12, 9, 30240, 1018100, <_UnixSelecto...se debug=True>, True) created at /usr/local/lib/python3.6/asyncio/selector_events.py:298>
source_traceback: Object created at (most recent call last):
  File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/alfa_promo/__main__.py", line 6, in <module>
    run_app(alfa_promo.application, host='0.0.0.0', port=5897)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web.py", line 413, in run_app
    loop.run_forever()
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 421, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.6/asyncio/base_events.py", line 1417, in _run_once
    handle._run()
  File "/usr/local/lib/python3.6/asyncio/events.py", line 126, in _run
    self._callback(*self._args)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 432, in start
    yield from resp.prepare(request)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 238, in prepare
    return (yield from self._sendfile(request, fobj, count))
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 126, in _sendfile_system
    yield from writer.sendfile(fobj, count)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 75, in sendfile
    self._sendfile_cb(fut, out_fd, in_fd, offset, count, loop, False)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 53, in _sendfile_cb
    offset + n, count - n, loop, True)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 347, in add_writer
    return self._add_writer(fd, callback, *args)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 298, in _add_writer
    handle = events.Handle(callback, args, self)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/asyncio/events.py", line 126, in _run
    self._callback(*self._args)
  File "/root/.virtualenvs/36/root/lib/python3.6/site-packages/aiohttp/web_fileresponse.py", line 37, in _sendfile_cb
    loop.remove_writer(out_fd)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 351, in remove_writer
    self._ensure_fd_no_transport(fd)
  File "/usr/local/lib/python3.6/asyncio/selector_events.py", line 258, in _ensure_fd_no_transport
    fd, transport))
asvetlov commented 7 years ago

We should silently ignore this exception. Any volunteer?

AlexanderMartynoff commented 7 years ago

Not only ignore, it is accompanied by the application's hangup, if necessary I can give a more detailed report

asvetlov commented 7 years ago

The idea is catching disconnection errors in web_fileresponse.py and stopping payload sending. Would you work on it?

AlexanderMartynoff commented 7 years ago

Yes, I can, as will be my free time I will try