Added exception handling to destructor in case of connection failure

This commit is contained in:
Roy Hyunjin Han 2012-04-19 17:03:30 -04:00
commit 1f8fc10661
4 changed files with 12 additions and 5 deletions

View file

@ -31,8 +31,11 @@ class SocketIO(object):
self.connection = create_connection('ws://%s:%d/socket.io/1/websocket/%s' % (self.host, self.port, self.sessionID))
def __del__(self):
self.heartbeatThread.cancel()
self.connection.close()
try:
self.heartbeatThread.cancel()
self.connection.close()
except AttributeError:
pass
def __send_heartbeat(self):
self.connection.send('2::')

Binary file not shown.