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

@ -1,3 +1,7 @@
0.1
---
0.1.1
-----
- Added exception handling to destructor in case of connection failure
0.1.0
-----
- Wrapped code from `StackOverflow <http://stackoverflow.com/questions/6692908/formatting-messages-to-send-to-socket-io-node-js-server-from-python-client/>`_

View file

@ -10,7 +10,7 @@ CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
setup(
name='socketIO-client',
version='0.1',
version='0.1.1',
description='Barebones socket.io client library',
long_description=README + '\n\n' + CHANGES,
license='MIT',

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.