evilkost / brukva

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

Reconnection stops working #6

Closed kmike closed 13 years ago

kmike commented 13 years ago

I think it stops working after this change: https://github.com/evilkost/brukva/commit/6f5514c1782fa7d8411bf3b3b330e40f4f725eec#L1R321

_sudden_disconnect is raising exception now but on_reconnect is usually called after _sudden_disconnect. Exception pops up and prevents reconnection. This is quite easy to reproduce if redis is executed with 'timeout 1' option.

The traceback (not so useful though):

ERROR:brukva.client:Socket closed on remote end
ERROR:root:Exception in callback <functools.partial object at 0x102966470>
Traceback (most recent call last):
  File "/Users/kmike/svn/tornado/tornado/ioloop.py", line 345, in _run_callback
    callback()
  File "/Users/kmike/svn/tornado/tornado/stack_context.py", line 173, in wrapped
    callback(*args, **kwargs)
  File "/Users/kmike/svn/brukva/brukva/adisp.py", line 111, in _send_result
    self.call(self.g.throw(result))
  File "/Users/kmike/dev/planor/realtime/handlers/pubsub.py", line 27, in change_active_sessions_count
    session_count = yield self.redis.async.hincrby('active_sessions', sessionid, diff)
ConnectionError: Socket closed on remote end
evilkost commented 13 years ago

I think it's fixed here: branch reconnect . Can you confirm for your case?

kmike commented 13 years ago

Hi, thanks for working on this! I can confirm that reconnections works in my case now.

The recent changes seems to broke the assumption that brukva.client.Client.listen callbacks will receive brukva.client.Message instance as a first parameter (sometimes None is received and it causes AttributeErrors in my code). That's easy to fix on my side though. Is this change intended?

evilkost commented 13 years ago

sometimes None is received and it causes AttributeErrors in my code

This is a bug, i am sure it is related to issue #7 Please check latest version: d47eff4, it should work now.

kmike commented 13 years ago

Yes, I can't reproduce AttributeErrors with the latest version.