Skip to content
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

close Connection socket after server disconnect #1552

Merged
merged 1 commit into from
Dec 17, 2021

Conversation

pawl
Copy link
Contributor

@pawl pawl commented Dec 17, 2021

This is similar to: redis/redis-py#1797

Currently, calibre/srv/loop.py's Connection.close() won't continue to close the socket if it encounters an OSError on socket.shutdown. An OSError can happen on socket.shutdown if the other side of the connection disconnected already. Not running socket.close prevents garbage collection from cleaning up the socket and will use more memory than necessary (maybe even causing a leak?).

This PR puts a separate try/except around socket.close and socket.shutdown to allow the socket to be closed after a failed shutdown.

@kovidgoyal kovidgoyal merged commit 1127c28 into kovidgoyal:master Dec 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants