Skip to content

Commit

Permalink
More respect stop event even in _consume (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wh1isper authored Sep 3, 2024
1 parent 55b9a82 commit bed83f2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions brq/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ async def _set_retry_timeout(self):
await self.redis.set(self.retry_cooldown_key, "1", ex=self.retry_cooldown_time)

async def _consume(self):
if self._stop_event.is_set():
return
try:
if not await self._is_retry_cooldown() and await self._acquire_retry_lock():
await self._process_unacked_job()
Expand All @@ -181,6 +183,8 @@ async def _consume(self):
finally:
await self._release_retry_lock()

if self._stop_event.is_set():
return
if self.run_parallel:
await self._pool_job_prallel()
else:
Expand Down

0 comments on commit bed83f2

Please sign in to comment.