Skip to content

Commit

Permalink
Rely on close() to close sockets and stop using shutdown()
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaneHarvey authored and arp102 committed Jul 26, 2024
1 parent 4d3b5a5 commit 64e4f18
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 5 deletions.
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

0 comments on commit 64e4f18

Please sign in to comment.