Skip to content

Commit

Permalink
python: wait for jobs to finalize on close
Browse files Browse the repository at this point in the history
  • Loading branch information
klaemo committed Apr 26, 2024
1 parent a7a7f4f commit 54a00fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion python/bullmq/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,13 +243,18 @@ async def runStalledJobsCheck(self):

async def close(self, force: bool = False):
"""
Close the worker
Closes the worker and related redis connections.
This method waits for current jobs to finalize before returning.
"""
self.closing = True
if force:
self.forceClosing = True
self.cancelProcessing()

if not force and len(self.processing) > 0:
await asyncio.wait(self.processing, return_when=asyncio.ALL_COMPLETED)

await self.blockingRedisConnection.close()
await self.redisConnection.close()

Expand Down

0 comments on commit 54a00fa

Please sign in to comment.