diff --git a/python/bullmq/scripts.py b/python/bullmq/scripts.py index c997fb6c55..7f7550509b 100644 --- a/python/bullmq/scripts.py +++ b/python/bullmq/scripts.py @@ -424,15 +424,25 @@ def pause(self, pause: bool = True): async def obliterate(self, count: int, force: bool = False): """ - Remove a queue completely + Remove a queue completely. + This command calls a Lua script that obliterates the queue + and removes all associated keys, including from bullmq:registry. """ - keys = self.getKeys(['bullmq:registry', 'meta', '']) - result = await self.commands["obliterate"](keys, args=[count, force or ""]) - if (result < 0): - if (result == -1): - raise Exception("Cannot obliterate non-paused queue") - if (result == -2): - raise Exception("Cannot obliterate queue with active jobs") + keys = ['bullmq:registry', *self.getKeys(['meta', ''])] + + # Convert force=True to "1", force=False to "", matching the Lua script logic + force_arg = '1' if force else '' + + # Pass "args" as expected by your commands["obliterate"] method + result = await self.commands["obliterate"](keys, args=[count, force_arg]) + + # If the script returns a negative code, raise an exception + if result < 0: + if result == -1: + raise Exception("Cannot obliterate a non-paused queue") + elif result == -2: + raise Exception("Cannot obliterate a queue with active jobs") + return result def moveJobsToWaitArgs(self, state: str, count: int, timestamp: int) -> int: