-
Notifications
You must be signed in to change notification settings - Fork 3.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
[wsrelay] Give connection tasks time to clean up #14097
Conversation
were you able to reproduce the scenario that logged the "Task was destroyed.." message? |
I wasn't able to reproduce it, but I am fairly confident that this would cause that in some conditions. Even if there's something else causing that, this is still something that I think needs to be fixed. |
https://bugs.python.org/issue44665 - This is kind of a reference, if you need a citation 😄 And it specifically mentions the error we're seeing. The issue itself is about adding asyncio documentation to prevent doing exactly what the current code is doing (killing off the strong reference to the task before it is completed). This seems to be a well-known phenomenon in python asyncio, you have to keep a strong reference around to tasks you create with |
Needs a rebase. I also kind of liked the callback method in the python bug you linked You should consider my comment about running these concurrently, but either way there is probably little risk because removing a node is an infrequent task and this is unlikely to choke because the main loop gets stalled waiting for the cancellations. |
When we close/cancel a connection to a web node, give the task time to clean up after itself and cleanly exit. Otherwise, the Python GC might clean up the task too early and this leads to ugly log messages like this: "Task was destroyed but it is pending!" Signed-off-by: Rick Elrod <[email protected]>
4249f33
to
272b91c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, very async
SUMMARY
When we close/cancel a connection to a web node, give the task time to clean up after itself and cleanly exit. Otherwise, the Python GC might clean up the task too early and this leads to ugly log messages like this: "Task was destroyed but it is pending!"
ISSUE TYPE
COMPONENT NAME