unhandled exception during asyncio.run() shutdown
task: <Task finished coro=<Application._handle() done, defined at /usr/lib/python3.5/site-packages/aiohttp/web_app.py:405> exception=<HTTPNotFound Not Found eof>
File "/usr/lib/python3.5/site-packages/aiohttp/web_protocol.py", line 406, in start
resp = await task
File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
yield self # This tells Task to wait for completion.
File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/usr/lib/python3.5/site-packages/aiohttp/web_app.py", line 435, in _handle
resp = await handler(request)
File "/usr/lib/python3.5/site-packages/aiohttp/web_urldispatcher.py", line 848, in _handle
raise self._http_exception
aiohttp.web_exceptions.HTTPNotFound: Not Found
Long story short
Python 3.5's
asyncio.Task.all_tasksdiffers from Python 3.7'sasyncio.all_tasksin that it includes completed tasks. However, theall_taskshelper uses them interchangeably.This means that when you shutdown a server started with
web.run_appon Python 3.5 or 3.6, failed requests are rethrown as exceptions inweb._cancel_all_tasks, whether they were handled or not.Steps to reproduce
python3.5 -c 'from aiohttp import web; web.run_app(web.Application())'Expected behaviour
Actual behaviour