Skip to content

Commit

Permalink
fix taskiq-python#65: avoid worker crash in case connection is broken
Browse files Browse the repository at this point in the history
  • Loading branch information
khizunov committed Jul 1, 2024
1 parent 65a0b6c commit ece9df8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions taskiq_redis/redis_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ async def listen(self) -> AsyncGenerator[bytes, None]:
:yields: broker messages.
"""
redis_brpop_data_position = 1
async with Redis(connection_pool=self.connection_pool) as redis_conn:
while True:
yield (await redis_conn.brpop(self.queue_name))[
redis_brpop_data_position
]
while True:
try:
async with Redis(connection_pool=self.connection_pool) as redis_conn:
yield (await redis_conn.brpop(self.queue_name))[
redis_brpop_data_position
]
except ConnectionError as exc:
logger.warning("Redis connection error: %s", exc)
continue

0 comments on commit ece9df8

Please sign in to comment.