When I close the WebSocket my python program prints out the following error:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/brukva/client.py", line 926, in listen
data = yield async(self.connection.readline)()
GeneratorExit: Connection lost
Exception AttributeError: "'ConnectionError' object has no attribute 'body'" in ignored
Although the connection to redis gets closed I still receive that error.
Here a snippet of the code I use:
c = brukva.Client()
def __init__(self, *args, **kwargs):
super(WSHandler, self).__init__(*args, **kwargs)
self.client = brukva.Client()
def on_message(self, message):
print('message received %s' %message.body)
+1 , this happens to me also when using tornadio2,
any work around?
Seems like unsubscribing is done asynchronously and the connection is closed before unsubscribing finishes which includes sending messages to the subscriptions.
My workaround is to delay disconnect():
# Disconnect connection after delay due to this issue: https://github.com/evilkost/brukva/issues/25
t = Timer(0.1, self.client.disconnect)
Not the nicest one though...
+1 ouch, a timer, the problem can still occur if it takes longer than the block period
print 'Connection still in progress'
This should work. It makes sure the connection is ready to be disconnected without blocking. It also might work on the disconnect method in brukva but I'm not sure the implications. It might be tweaked by forcing the disconnect after a certain amount of time or iterations.
Same. Probably it isn't bug but feature?
Will someone fix it in source? Code below doesn't look well but it works.