Skip to content

Commit

Permalink
Ignore ENOTCONN during shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
tipabu authored and arp102 committed Jul 26, 2024
1 parent 9d5b287 commit 6cd44b5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions kmip/services/server/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# under the License.

import binascii
import errno
import logging
import socket
import struct
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit 6cd44b5

Please sign in to comment.