From 6cd44b572b0ca55adf01a8a12078b2284602e64c Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Tue, 16 Jan 2024 17:07:09 -0800 Subject: [PATCH] Ignore ENOTCONN during shutdown --- kmip/services/server/session.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kmip/services/server/session.py b/kmip/services/server/session.py index c6a5f70c..887f1c83 100644 --- a/kmip/services/server/session.py +++ b/kmip/services/server/session.py @@ -14,6 +14,7 @@ # under the License. import binascii +import errno import logging import socket import struct @@ -113,8 +114,13 @@ def run(self): self._logger.info("Failure handling message loop") self._logger.exception(e) - self._connection.shutdown(socket.SHUT_RDWR) - self._connection.close() + try: + self._connection.shutdown(socket.SHUT_RDWR) + except OSError as e: + if e.errno != errno.ENOTCONN: + raise + finally: + self._connection.close() self._logger.info("Stopping session: {0}".format(self.name)) def _handle_message_loop(self):