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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions kmip/services/kmip_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,9 @@ def __del__(self):
self.close()

def close(self):
# Shutdown and close the socket.
# Close the socket.
if self.socket:
try:
self.socket.shutdown(socket.SHUT_RDWR)
self.socket.close()
except (OSError, socket.error):
# Can be thrown if the socket is not actually connected to
Expand Down
3 changes: 1 addition & 2 deletions kmip/services/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,12 +362,11 @@ def stop(self):

self._logger.info("Shutting down server socket handler.")
try:
self._socket.shutdown(socket.SHUT_RDWR)
self._socket.close()
except Exception as e:
self._logger.exception(e)
raise exceptions.NetworkingError(
"Server failed to shutdown socket handler."
"Server failed to close socket handler."
)

if hasattr(self, "policy_monitor"):
Expand Down
1 change: 0 additions & 1 deletion kmip/services/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ def run(self):
self._logger.info("Failure handling message loop")
self._logger.exception(e)

self._connection.shutdown(socket.SHUT_RDWR)
self._connection.close()
self._logger.info("Stopping session: {0}".format(self.name))

Expand Down