evilkost / brukva

Asynchronous Redis client that works within Tornado IO loop.
Other
265 stars 33 forks source link

Trouble disconnecting clients due to ConnectionError #15

Open dkellerman opened 13 years ago

dkellerman commented 13 years ago

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!

patrickod commented 12 years ago

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.

nellessen commented 12 years ago

Might be related to https://github.com/evilkost/brukva/issues/25 ?

shadda commented 11 years ago

This is still happening, is there any work around?