mirror of https://github.com/OpenKMIP/PyKMIP.git
Rely on close() to close sockets and stop using shutdown()
This commit is contained in:
parent
4d3b5a52ae
commit
64e4f18dd0
|
@ -301,10 +301,9 @@ class KMIPProxy(object):
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
# Shutdown and close the socket.
|
# Close the socket.
|
||||||
if self.socket:
|
if self.socket:
|
||||||
try:
|
try:
|
||||||
self.socket.shutdown(socket.SHUT_RDWR)
|
|
||||||
self.socket.close()
|
self.socket.close()
|
||||||
except (OSError, socket.error):
|
except (OSError, socket.error):
|
||||||
# Can be thrown if the socket is not actually connected to
|
# Can be thrown if the socket is not actually connected to
|
||||||
|
|
|
@ -362,12 +362,11 @@ class KmipServer(object):
|
||||||
|
|
||||||
self._logger.info("Shutting down server socket handler.")
|
self._logger.info("Shutting down server socket handler.")
|
||||||
try:
|
try:
|
||||||
self._socket.shutdown(socket.SHUT_RDWR)
|
|
||||||
self._socket.close()
|
self._socket.close()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self._logger.exception(e)
|
self._logger.exception(e)
|
||||||
raise exceptions.NetworkingError(
|
raise exceptions.NetworkingError(
|
||||||
"Server failed to shutdown socket handler."
|
"Server failed to close socket handler."
|
||||||
)
|
)
|
||||||
|
|
||||||
if hasattr(self, "policy_monitor"):
|
if hasattr(self, "policy_monitor"):
|
||||||
|
|
|
@ -113,7 +113,6 @@ class KmipSession(threading.Thread):
|
||||||
self._logger.info("Failure handling message loop")
|
self._logger.info("Failure handling message loop")
|
||||||
self._logger.exception(e)
|
self._logger.exception(e)
|
||||||
|
|
||||||
self._connection.shutdown(socket.SHUT_RDWR)
|
|
||||||
self._connection.close()
|
self._connection.close()
|
||||||
self._logger.info("Stopping session: {0}".format(self.name))
|
self._logger.info("Stopping session: {0}".format(self.name))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue