Server disconnection works properly

This commit is contained in:
nemunaire 2014-08-31 10:51:44 +02:00
commit 038590c659
4 changed files with 5 additions and 5 deletions

View file

@ -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

View file

@ -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