In different occasions close() might be called more than once, causing problems with already disconnected sockets/dispatchers.
connected = False
accepting = False
- closing = False
+ closed = False
addr = None
ignore_log_types = frozenset(['warning'])
raise
def close(self):
- self.connected = False
- self.accepting = False
- self.del_channel()
- try:
- self.socket.close()
- except socket.error as why:
- if why.args[0] not in (ENOTCONN, EBADF):
- raise
+ if not self.closed:
+ self.closed = True
+ self.connected = False
+ self.accepting = False
+ self.del_channel()
+ try:
+ self.socket.close()
+ except socket.error as why:
+ if why.args[0] not in (ENOTCONN, EBADF):
+ raise
# cheap inheritance, used to pass all other attribute
# references to the underlying socket object.