Cache socket fileno in IRCServer.Server just before disconnecting
This commit is contained in:
parent
fa3fc7e3fb
commit
c3f654673a
1 changed files with 3 additions and 1 deletions
|
@ -39,6 +39,7 @@ class Server(IRCObject.Object):
|
||||||
self.buffered_lines = [] # type: typing.List[bytes]
|
self.buffered_lines = [] # type: typing.List[bytes]
|
||||||
self.read_buffer = b""
|
self.read_buffer = b""
|
||||||
self.recent_sends = [] # type: typing.List[float]
|
self.recent_sends = [] # type: typing.List[float]
|
||||||
|
self.cached_fileno = None # type: typing.Optional[int]
|
||||||
|
|
||||||
self.users = {} # type: typing.Dict[str, IRCUser.User]
|
self.users = {} # type: typing.Dict[str, IRCUser.User]
|
||||||
self.new_users = set([]) #type: typing.Set[IRCUser.User]
|
self.new_users = set([]) #type: typing.Set[IRCUser.User]
|
||||||
|
@ -69,7 +70,7 @@ class Server(IRCObject.Object):
|
||||||
return "%s:%s%s" % (self.target_hostname, "+" if self.tls else "",
|
return "%s:%s%s" % (self.target_hostname, "+" if self.tls else "",
|
||||||
self.port)
|
self.port)
|
||||||
def fileno(self):
|
def fileno(self):
|
||||||
return self.socket.fileno()
|
return self.cached_fileno or self.socket.fileno()
|
||||||
|
|
||||||
def tls_wrap(self):
|
def tls_wrap(self):
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||||
|
@ -107,6 +108,7 @@ class Server(IRCObject.Object):
|
||||||
self.send_nick(self.original_nickname)
|
self.send_nick(self.original_nickname)
|
||||||
self.connected = True
|
self.connected = True
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
|
self.cached_fileno = self.socket.fileno()
|
||||||
self.connected = False
|
self.connected = False
|
||||||
try:
|
try:
|
||||||
self.socket.shutdown(socket.SHUT_RDWR)
|
self.socket.shutdown(socket.SHUT_RDWR)
|
||||||
|
|
Loading…
Reference in a new issue