Skip to content

run_in_thread dies if reconnection fails #816

@jkarneges

Description

@jkarneges

PubSubWorkerThread.run loops on a call to get_message. If the connection is lost, this call will silently attempt reconnection. However, if a single reconnect attempt fails, then an exception will bubble up. Since there is nobody to catch the exception, the thread dies.

An easy way to reproduce the issue is to set up a subscription and then restart the Redis server. On my machine, Redis takes a few seconds to restart. redis-py will attempt to reconnect faster than this and get a connection refused error. I would have expected redis-py to simply eventually reconnect after the Redis server comes back up.

I believe what is needed here is a way for the PubSubWorkerThread to reconnect multiple times until success. Putting a try/except around the call to get_message does the trick, but I don't know if that's the right answer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions