From 2f5628feffab66cdcc78abf4d7bb608bdcaa65bb Mon Sep 17 00:00:00 2001 From: Rogger Valverde Date: Tue, 12 Sep 2023 00:19:56 -0600 Subject: [PATCH] fix(remove): change error message when job is locked (python) (#2175) --- docs/gitbook/changelog.md | 2 -- docs/gitbook/python/changelog.md | 19 ++----------------- package.json | 2 +- python/bullmq/job.py | 2 +- src/classes/job.ts | 4 +++- src/commands/removeJob-1.lua | 8 -------- tests/test_flow.ts | 2 +- 7 files changed, 8 insertions(+), 31 deletions(-) diff --git a/docs/gitbook/changelog.md b/docs/gitbook/changelog.md index 6e32ab2626..55b8eccf9b 100644 --- a/docs/gitbook/changelog.md +++ b/docs/gitbook/changelog.md @@ -4,8 +4,6 @@ ### Features * **connection:** provide skipVersionCheck option for shared connections ([#2149](https://github.com/taskforcesh/bullmq/issues/2149)) ref [#2148](https://github.com/taskforcesh/bullmq/issues/2148) ([914820f](https://github.com/taskforcesh/bullmq/commit/914820f720cbc48b49f4bd1c46d148eb2bb5b79c)) -* **python:** add addBulk method in queue class ([#2161](https://github.com/taskforcesh/bullmq/issues/2161)) ([555dd44](https://github.com/taskforcesh/bullmq/commit/555dd44a0190f4957e43f083e2f59d7f58b90ac9)) -* **python:** add flow producer class ([#2115](https://github.com/taskforcesh/bullmq/issues/2115)) ([14a769b](https://github.com/taskforcesh/bullmq/commit/14a769b193d97576ff9b3f2a65de47463ba04ffd)) # [4.8.0](https://github.com/taskforcesh/bullmq/compare/v4.7.4...v4.8.0) (2023-08-20) diff --git a/docs/gitbook/python/changelog.md b/docs/gitbook/python/changelog.md index f095deeaba..09754d71ad 100644 --- a/docs/gitbook/python/changelog.md +++ b/docs/gitbook/python/changelog.md @@ -9,29 +9,14 @@ ## v1.13.0 (2023-09-07) ### Feature * **flow-producer:** Add addBulk method (python) ([#2174](https://github.com/taskforcesh/bullmq/issues/2174)) ([`c67dfb4`](https://github.com/taskforcesh/bullmq/commit/c67dfb49931ee4cb96573af660e9f2316942687c)) -* **connection:** Provide skipVersionCheck option for shared connections (#2149) ref #2148 ([`914820f`](https://github.com/taskforcesh/bullmq/commit/914820f720cbc48b49f4bd1c46d148eb2bb5b79c)) - -### Documentation -* **auto-removal:** Clarify removal regardless of job names ([`bab0c61`](https://github.com/taskforcesh/bullmq/commit/bab0c6168f22af4e6aa7e9c47ecaad226d8fbf1d)) -* **python:** Add flowProducer usage ([#2163](https://github.com/taskforcesh/bullmq/issues/2163)) ([`96f84b7`](https://github.com/taskforcesh/bullmq/commit/96f84b7efb4d187ddeab3169c833c35e7786e608)) ## v1.12.0 (2023-08-31) ### Feature -* **python:** Add addBulk method in queue class ([#2161](https://github.com/taskforcesh/bullmq/issues/2161)) ([`555dd44`](https://github.com/taskforcesh/bullmq/commit/555dd44a0190f4957e43f083e2f59d7f58b90ac9)) - -### Documentation -* **typedoc:** Change defaultValue tag styling ([#2160](https://github.com/taskforcesh/bullmq/issues/2160)) ([`1b0ff8e`](https://github.com/taskforcesh/bullmq/commit/1b0ff8ef51e27df906a93dae317534e2c2e9ccb3)) +* **queue:** Add addBulk method ([#2161](https://github.com/taskforcesh/bullmq/issues/2161)) ([`555dd44`](https://github.com/taskforcesh/bullmq/commit/555dd44a0190f4957e43f083e2f59d7f58b90ac9)) ## v1.11.0 (2023-08-26) ### Feature -* **python:** Add flow producer class ([#2115](https://github.com/taskforcesh/bullmq/issues/2115)) ([`14a769b`](https://github.com/taskforcesh/bullmq/commit/14a769b193d97576ff9b3f2a65de47463ba04ffd)) -* **sandbox:** Emulate moveToDelayed method (#2122) ref #2118 ([`4c4559b`](https://github.com/taskforcesh/bullmq/commit/4c4559b3c678313b3727c9781a6d3f963bcfda4e)) - -### Fix -* **sandbox:** Ignore extra params on processor ([#2142](https://github.com/taskforcesh/bullmq/issues/2142)) ([`3602c20`](https://github.com/taskforcesh/bullmq/commit/3602c20ab80cbe0a0d3de66210a01ad119e1090b)) - -### Documentation -* **rate-limit:** Add getRateLimitTtl usage ([#2116](https://github.com/taskforcesh/bullmq/issues/2116)) ([`51219fd`](https://github.com/taskforcesh/bullmq/commit/51219fd8685ccf1703548dda49303cd03690a95e)) +* Add flow producer class ([#2115](https://github.com/taskforcesh/bullmq/issues/2115)) ([`14a769b`](https://github.com/taskforcesh/bullmq/commit/14a769b193d97576ff9b3f2a65de47463ba04ffd)) ## v1.10.1 (2023-08-19) ### Fix diff --git a/package.json b/package.json index af8a314221..fd251ff8ca 100644 --- a/package.json +++ b/package.json @@ -174,7 +174,7 @@ { "releaseRules": [ { - "message": "*[python]*", + "message": "*\\[python\\]*", "release": false } ] diff --git a/python/bullmq/job.py b/python/bullmq/job.py index d50251386b..80ac2dac91 100644 --- a/python/bullmq/job.py +++ b/python/bullmq/job.py @@ -83,7 +83,7 @@ async def remove(self, opts: dict = {}): removed = await self.scripts.remove(self.id, opts.get("removeChildren", True)) if not removed: - raise Exception(f"Could not remove job {self.id}") + raise Exception(f"Job {self.id} could not be removed because it is locked by another worker") async def moveToFailed(self, err, token:str, fetchNext:bool = False): error_message = str(err) diff --git a/src/classes/job.ts b/src/classes/job.ts index 54a7e49b43..f457b92121 100644 --- a/src/classes/job.ts +++ b/src/classes/job.ts @@ -516,7 +516,9 @@ export class Job< if (removed) { queue.emit('removed', job); } else { - throw new Error('Could not remove job ' + job.id); + throw new Error( + `Job ${this.id} could not be removed because it is locked by another worker`, + ); } } diff --git a/src/commands/removeJob-1.lua b/src/commands/removeJob-1.lua index 9016b19d5d..ac8a3cedc3 100644 --- a/src/commands/removeJob-1.lua +++ b/src/commands/removeJob-1.lua @@ -55,14 +55,6 @@ local function removeJob( prefix, jobId, parentKey, removeChildren) rcall("DEL", jobKey, jobKey .. ":logs", jobKey .. ":dependencies", jobKey .. ":processed") - -- -- delete keys related to rate limiter - -- local limiterIndexTable = KEYS[10] .. ":index" - -- local limitedSetKey = rcall("HGET", limiterIndexTable, jobId) - -- if limitedSetKey then - -- rcall("SREM", limitedSetKey, jobId) - -- rcall("HDEL", limiterIndexTable, jobId) - -- end - rcall("XADD", prefix .. "events", "*", "event", "removed", "jobId", jobId, "prev", prev); end diff --git a/tests/test_flow.ts b/tests/test_flow.ts index 68325dcae3..b677fc0909 100644 --- a/tests/test_flow.ts +++ b/tests/test_flow.ts @@ -3079,7 +3079,7 @@ describe('flows', () => { expect(await (nextJob as Job).getState()).to.be.equal('active'); await expect(tree.job.remove()).to.be.rejectedWith( - `Could not remove job ${tree.job.id}`, + `Job ${tree.job.id} could not be removed because it is locked by another worker`, ); expect(await tree.job.getState()).to.be.equal('waiting-children');