Skip to content

What is the recommended socket timeout configuration for ListQueueBroker with redis-py 8? #127

Description

@leonelfreire

Context

After upgrading to taskiq-redis 1.2.3 and redis-py 8.0.1, workers using ListQueueBroker terminate when the queue remains empty for approximately five seconds.

redis-py 8 changed the default socket_timeout from None to 5 seconds. ListQueueBroker.listen() uses an indefinitely blocking BRPOP, so the socket timeout is reached while it waits for a message.

Environment

  • Python: 3.14
  • taskiq: 0.12.4
  • taskiq-redis: 1.2.3
  • redis-py: 8.0.1
  • Server: Valkey 9.0.3

Minimal configuration

from taskiq_redis import ListQueueBroker

broker = ListQueueBroker("redis://valkey:6379")

Start the worker and leave the queue empty:

taskiq worker module:broker

Observed behavior

After approximately five seconds, BRPOP raises a socket read timeout:

File "taskiq_redis/redis_broker.py", line 132, in listen
    brpop_result = await redis_conn.brpop(self.queue_name)

redis.exceptions.TimeoutError: Timeout reading from valkey:6379

The exception propagates through the receiver and the process manager restarts the worker:

worker-0 is dead. Scheduling reload.
worker-1 is dead. Scheduling reload.

This repeats while the queue remains empty.

Explicitly disabling the socket read timeout appears to prevent the restarts:

broker = ListQueueBroker(
    "redis://valkey:6379",
    socket_timeout=None,
)

Questions

Is socket_timeout=None the recommended configuration for ListQueueBroker with redis-py 8?

Should applications configure this explicitly, or is ListQueueBroker expected to account for the indefinitely blocking BRPOP internally, for example by using a finite polling timeout or handling redis.exceptions.TimeoutError?

If explicit configuration is expected, would it make sense to document this interaction?

Related references

I could not find this interaction mentioned in the taskiq-redis 1.2.3 release notes or README.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions