-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
websocket: Task was destroyed but it is pending! #2763
Comments
If this message occurs while the process is shutting down, it's generally harmless - it just means that the process is only partially cleaning up after itself. I recommend ignoring it, but if you want to work towards a cleaner shutdown, you need to close all your websocket connections before stopping the event loop. This message comes from asyncio rather than Tornado, so there's not much Tornado can do to control it. |
I have the same RuntimeWarning, but it doesn't occur only on shut down. I get this warning constantly while my websocket is open. I know it comes from asyncio, but the Tornado is talking to asyncio. I am using tornado 6.0.3 with python 3.7 |
Hmm. There's only one Are you also on windows? There are reports of issues with websockets on windows that are not understood: #2136. |
Hi @bdarnell , I faced the same problem as @afzoun. you can reproduce the error by running the cam_server.py. Please rename the index.txt to index.html (github does not allow me upload html file) Please rename the cam_server.txt to cam_server.py (github does not allow me upload python file) |
@tankienleong in your example you call |
Per the warning in the asyncio documentation, we need to hold a strong reference to all asyncio Tasks to prevent premature GC. Following discussions in cpython (python/cpython#91887), we hold these references on the IOLoop instance to ensure that they are strongly held but do not cause leaks if the event loop itself is discarded. This is expected to fix all of the various "task was destroyed but it is pending" warnings that have been reported. The IOLoop._pending_tasks set is expected to become obsolete if corresponding changes are made to asyncio in Python 3.13. Fixes tornadoweb#3209 Fixes tornadoweb#3047 Fixes tornadoweb#2763 Some issues involve this warning as their most visible symptom, but have an underlying cause that should still be addressed. Updates tornadoweb#2914 Updates tornadoweb#2356
Per the warning in the asyncio documentation, we need to hold a strong reference to all asyncio Tasks to prevent premature GC. Following discussions in cpython (python/cpython#91887), we hold these references on the IOLoop instance to ensure that they are strongly held but do not cause leaks if the event loop itself is discarded. This is expected to fix all of the various "task was destroyed but it is pending" warnings that have been reported. The IOLoop._pending_tasks set is expected to become obsolete if corresponding changes are made to asyncio in Python 3.13. Fixes tornadoweb#3209 Fixes tornadoweb#3047 Fixes tornadoweb#2763 Some issues involve this warning as their most visible symptom, but have an underlying cause that should still be addressed. Updates tornadoweb#2914 Updates tornadoweb#2356 (cherry picked from commit bffed1a)
[E 191029 10:54:51 base_events:1608] Task was destroyed but it is pending!
task: <Task pending coro=<WebSocketProtocol13._receive_frame_loop() done, defined at D:\AndroidControl\Python37\lib\site-packages\tornado\websocket.py:1115> wait_for=<Future pending cb=[IOLoop.add_future..() at D:\AndroidControl\Python37\lib\site-packages\tornado\ioloop.py:690, <TaskWakeupMethWrapper object at 0x000002AC48174468>()]> cb=[IOLoop.add_future..() at D:\AndroidControl\Python37\lib\site-packages\tornado\ioloop.py:690]>
The text was updated successfully, but these errors were encountered: