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

Rely on close() to close sockets and stop using shutdown() #682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShaneHarvey
Copy link

I see this error when a client closes a connection to the server:

 [2022/08/19 00:09:02.481] Traceback (most recent call last):
 [2022/08/19 00:09:02.481]   File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
 [2022/08/19 00:09:02.482]     self.run()
 [2022/08/19 00:09:02.482]   File "/System/Volumes/Data/data/mci/d2010f3ec27c908e548f765abcafefe8/drivers-tools/.evergreen/csfle/kmstlsvenv/lib/python3.9/site-packages/kmip/services/server/session.py", line 116, in run
 [2022/08/19 00:09:02.482]     self._connection.shutdown(socket.SHUT_RDWR)
 [2022/08/19 00:09:02.482]   File "/usr/local/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ssl.py", line 1280, in shutdown
 [2022/08/19 00:09:02.490]     super().shutdown(how)
 [2022/08/19 00:09:02.490] OSError: [Errno 57] Socket is not connected

The prevailing wisdom I've seen is to rely on socket.close() to cleanup the connection and not use socket.shutdown() unless for very niche reasons. Since this library isn't doing any funky like using a socket simultaneously in multiple threads/processes and is always calling close() directly after shutdown(SHUT_RDWR) it will be simpler and more robust to just call close().

@ShaneHarvey
Copy link
Author

Any thoughts here?

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.

None yet

2 participants