Skip to content

Commit

Permalink
Return unprocessed daed job (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper authored Aug 14, 2024
1 parent 5ab7b86 commit 024f0cf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion brq/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,21 @@ async def _consume(self):
else:
await self._pool_job()

async def process_dead_jobs(self, raise_exception: bool = False):
async def process_dead_jobs(self, raise_exception: bool = False) -> list[Job]:
unprocessed_jobs = []
for job in (Job.from_redis(j) for j in await self.redis.zrange(self.dead_key, 0, -1)):
try:
await self.awaitable_function(*job.args, **job.kwargs)
except Exception as e:
logger.exception(e)
unprocessed_jobs.append(job)
if raise_exception:
raise e
else:
await self.redis.zrem(self.dead_key, job.to_redis())

return unprocessed_jobs

async def _move_expired_jobs(self):
while True:
if self._stop_event.is_set():
Expand Down

0 comments on commit 024f0cf

Please sign in to comment.