asyncio-redis icon indicating copy to clipboard operation
asyncio-redis copied to clipboard

Bad handling of timeouts in pubsub subscriptions

Open mrdon opened this issue 9 years ago • 5 comments

Heroku addons like to timeout out connections, which this library doesn't handle well.

Fix at https://github.com/mrdon/asyncio-redis/commit/7edcd90834550f2ff214225eec434df65ce3e1e5

mrdon avatar Aug 24 '15 23:08 mrdon

mrdon's patch also fixes an issue with lost exception when Redis server dies/disconnects while the client is waiting for message. With 0.13.4 I got this error:

2015-10-22 13:42:59,090 [INFO] asyncio_redis:853 eof_received - EOF received in RedisProtocol
2015-10-22 13:42:59,091 [ERROR] asyncio:1008 default_exception_handler - Task exception was never retrieved
future: <Task finished coro=<_reader_coroutine() done, defined at /Users/rivo/Projektid/gridens/venv/lib/python3.4/site-packages/asyncio_redis/protocol.py:912> exception=IncompleteReadError('0 bytes read on a total of 1 expected bytes',)>
Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/tasks.py", line 238, in _step
    result = next(coro)
  File "/Users/rivo/Projektid/gridens/venv/lib/python3.4/site-packages/asyncio_redis/protocol.py", line 919, in _reader_coroutine
    yield from self._handle_item(self._push_answer)
  File "/Users/rivo/Projektid/gridens/venv/lib/python3.4/site-packages/asyncio_redis/protocol.py", line 927, in _handle_item
    c = yield from self._reader.readexactly(1)
  File "/usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/asyncio/streams.py", line 482, in readexactly
    raise IncompleteReadError(partial, len(partial) + n)
asyncio.streams.IncompleteReadError: 0 bytes read on a total of 1 expected bytes
2015-10-22 13:42:59,095 [INFO] asyncio_redis:877 connection_lost - Redis connection lost

With the patch, it works without printing any errors (and no noticeable changes in behavior).

rivol avatar Oct 22 '15 13:10 rivol

Ok, I'll have a second look later this week and I'll guess I will merge it if nobody is against.

Thanks for reporting everyone!

jonathanslenders avatar Oct 22 '15 14:10 jonathanslenders

Looks like it was not merged yet. Please fix. Thank you.

dk2ro avatar Feb 21 '16 04:02 dk2ro

Thanks for reminding me! It's merged in: https://github.com/jonathanslenders/asyncio-redis/commit/c524f915af02f523daaf47754f93fa0a464e28b4

I'll push a new release to Pypi very soon.

jonathanslenders avatar Feb 22 '16 21:02 jonathanslenders

Awesome, thanks @jonathanslenders !

madgnome avatar Feb 22 '16 21:02 madgnome