Skip to content

Commit 024f0cf

Browse files
authored
Return unprocessed daed job (#29)
1 parent 5ab7b86 commit 024f0cf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

brq/consumer.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -186,17 +186,21 @@ async def _consume(self):
186186
else:
187187
await self._pool_job()
188188

189-
async def process_dead_jobs(self, raise_exception: bool = False):
189+
async def process_dead_jobs(self, raise_exception: bool = False) -> list[Job]:
190+
unprocessed_jobs = []
190191
for job in (Job.from_redis(j) for j in await self.redis.zrange(self.dead_key, 0, -1)):
191192
try:
192193
await self.awaitable_function(*job.args, **job.kwargs)
193194
except Exception as e:
194195
logger.exception(e)
196+
unprocessed_jobs.append(job)
195197
if raise_exception:
196198
raise e
197199
else:
198200
await self.redis.zrem(self.dead_key, job.to_redis())
199201

202+
return unprocessed_jobs
203+
200204
async def _move_expired_jobs(self):
201205
while True:
202206
if self._stop_event.is_set():

0 commit comments

Comments
 (0)