Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't know this code so I don't know if the fix is correct or not. Why not always closing all connections? (why only on error)
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.
Thanks for jumping in, and good question, I'd like to know why I didn't put that info in my commit 🤦
I'm not sure what I was thinking at the time, but I'm no longer certain my change is the best handling of this situation.
Incoming brain dump
In the case of no error this would be closed by
ThreadedEchoServer.ConnectionHandler.close
. However, the test above causesThreadedEchoServer.ConnectionHandler.read
to raise an exception inThreadedEchoServer.ConnectionHandler.run
which is then caught at line 2489 of this file:Though it looks like you're already had some experience with this resource warning in that location:
I will note that I'm seeing that condition while not running on Windows (nor do I have one on hand at the moment), so not sure if that comment needs updating.
End brain dump
Something else that probably should've been in the coommit is some more context wtih
tracemalloc
: