Improve server socket problem detection

This commit is contained in:
Némunaire 2012-12-21 11:29:29 +01:00
commit 856feab62d
2 changed files with 19 additions and 10 deletions

View file

@ -126,7 +126,10 @@ class Server(threading.Thread):
"""Close the socket with the server"""
if self.connected:
self.stop = True
self.s.shutdown(socket.SHUT_RDWR)
try:
self.s.shutdown(socket.SHUT_RDWR)
except socket.error:
pass
self.stopping.wait()
return True
@ -139,7 +142,10 @@ class Server(threading.Thread):
self.stop = True
self.connected = False
#Send a message in order to close the socket
self.s.send(("Bye!\r\n" % self.nick).encode ())
try:
self.s.send(("Bye!\r\n" % self.nick).encode ())
except:
pass
self.stopping.wait()
return True
else: