Server disconnection works properly
This commit is contained in:
parent
dcce36eb7c
commit
038590c659
2
bot.py
2
bot.py
@ -394,7 +394,7 @@ class Bot(threading.Thread):
|
||||
logger.info("Close all servers connection...")
|
||||
k = list(self.servers.keys())
|
||||
for srv in k:
|
||||
self.servers[srv].disconnect()
|
||||
self.servers[srv].close()
|
||||
|
||||
self.stop = True
|
||||
|
||||
|
@ -87,6 +87,4 @@ if __name__ == "__main__":
|
||||
|
||||
print ("\nWaiting for other threads shuts down...")
|
||||
|
||||
# Indeed, the server socket is waiting for receiving some data
|
||||
|
||||
sys.exit(0)
|
||||
|
@ -70,9 +70,10 @@ class AbstractServer(io.IOBase):
|
||||
def write_select(self):
|
||||
"""Internal function used by the select function"""
|
||||
try:
|
||||
_wlist.remove(self)
|
||||
while not self._sending_queue.empty():
|
||||
self._write(self._sending_queue.get_nowait())
|
||||
_wlist.remove(self)
|
||||
self._sending_queue.task_done()
|
||||
|
||||
except queue.Empty:
|
||||
pass
|
||||
|
@ -57,8 +57,9 @@ class SocketServer(AbstractServer):
|
||||
return True
|
||||
|
||||
def _close(self):
|
||||
self._sending_queue.join()
|
||||
if self.socket is not None:
|
||||
self.socket.shutdown(SHUT_RDWR)
|
||||
self.socket.shutdown(socket.SHUT_RDWR)
|
||||
self.socket.close()
|
||||
self.socket = None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user