def close(self):
"""Close the socket from connection instance."""
self.state = ConnectionState.FINISHED
if self.switch and self.switch.connection is self:
self.switch.connection = None
LOG.debug('Shutting down Connection %s', self.id)
try:
self.socket.shutdown(SHUT_RDWR)
self.socket.close()
self.socket = None
LOG.debug('Connection Closed: %s', self.id)
except OSError as exception:
if exception.errno not in (ENOTCONN, EBADF):
raise exception
except AttributeError as exception:
LOG.debug('Socket Already Closed: %s', self.id)
评论列表
文章目录