Skip to content

Commit ece9df8

Browse files
committed
fix #65: avoid worker crash in case connection is broken
1 parent 65a0b6c commit ece9df8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

taskiq_redis/redis_broker.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,12 @@ async def listen(self) -> AsyncGenerator[bytes, None]:
123123
:yields: broker messages.
124124
"""
125125
redis_brpop_data_position = 1
126-
async with Redis(connection_pool=self.connection_pool) as redis_conn:
127-
while True:
128-
yield (await redis_conn.brpop(self.queue_name))[
129-
redis_brpop_data_position
130-
]
126+
while True:
127+
try:
128+
async with Redis(connection_pool=self.connection_pool) as redis_conn:
129+
yield (await redis_conn.brpop(self.queue_name))[
130+
redis_brpop_data_position
131+
]
132+
except ConnectionError as exc:
133+
logger.warning("Redis connection error: %s", exc)
134+
continue

0 commit comments

Comments
 (0)