brukva
brukva copied to clipboard
Trouble disconnecting clients due to ConnectionError
I'm not sure if this is an issue with brukva, or just something I don't understand about the best way to use it.
I have handler such as the following:
class MessageHandler(RequestHandler):
def __init__(self, *args, **kwargs):
super(MessageHandler, self).__init__(*args, **kwargs)
self.redis = brukva.Client()
self.redis.connect()
self.redis.subscribe('messages')
@tornado.web.asynchronous
@tornado.web.authenticated
def post(self):
self.redis.listen(self.on_new_message)
def on_new_message(self, result):
self.redis.unsubscribe('messages')
self.redis.disconnect()
self.finish(dict(
messages=tornado.escape.json_decode(result.body)
))
This works, but I see "ConnectionError('Tried to read from non-existent connection')" in the console - it seems to be happening after the on_new_message is done. If I take out the disconnect call it fixes it, but then all my connections stay open.
Do you know of any solution to this problem?
Thanks!
I'd also really appreciate any input on this. I'm trying to use short-term connections to redis but it seems that the disconnect function raises the ConnectionError.
Might be related to https://github.com/evilkost/brukva/issues/25 ?
This is still happening, is there any work around?