Revert "Rely on close() to close sockets and stop using shutdown()"

This reverts commit 64e4f18dd0
because it broke the CI tests.
This commit is contained in:
arp102 2024-07-26 11:33:07 -04:00
parent feec443cf8
commit 9d5b287f4c
3 changed files with 5 additions and 2 deletions

View File

@ -301,9 +301,10 @@ class KMIPProxy(object):
self.close()
def close(self):
# Close the socket.
# Shutdown and 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

View File

@ -362,11 +362,12 @@ class KmipServer(object):
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 close socket handler."
"Server failed to shutdown socket handler."
)
if hasattr(self, "policy_monitor"):

View File

@ -113,6 +113,7 @@ class KmipSession(threading.Thread):
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))