[GH-ISSUE #299] [BUG] cannot cancel task #121

Closed
opened 2026-03-02 05:18:52 +03:00 by kerem · 2 comments
Owner

Originally created by @nkbai on GitHub (Jul 22, 2021).
Original GitHub issue: https://github.com/hibiken/asynq/issues/299

Originally assigned to: @hibiken on GitHub.

my asynq version is 0.18.2,but i cannot cancel tasks.

 asynq task ls --queue=default --state=retry
ID                                    Type                        Payload                                                 Next Retry  Last Error                                               Last Failed                   Retried  Max Retry
--                                    ----                        -------                                                 ----------  ----------                                               -----------                   -------  ---------
99f712c3-37c0-493c-b121-56e8511765f4  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 2m25s    err count                                                Thu Jul 22 18:34:31 CST 2021  9        10
4ef669f6-de6e-47e2-a088-a1238d0f7d43  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 4m4s     err count                                                Thu Jul 22 18:34:31 CST 2021  9        10
5d06ccfc-4420-4bd9-b5ac-d60e66dae314  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 25m49s   err count                                                Thu Jul 22 18:59:25 CST 2021  9        10


➜  asynq git:(master) asynq --version
asynq version 0.18.2
➜  asynq git:(master) asynq task cancel 99f712c3-37c0-493c-b121-56e8511765f4
Sent cancelation signal for task 99f712c3-37c0-493c-b121-56e8511765f4

➜  asynq git:(master) asynq task ls --queue=default --state=retry
ID                                    Type                        Payload                                                 Next Retry   Last Error                                               Last Failed                   Retried  Max Retry
--                                    ----                        -------                                                 ----------   ----------                                               -----------                   -------  ---------
5d06ccfc-4420-4bd9-b5ac-d60e66dae314  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 13m31s    err count                                                Thu Jul 22 18:59:25 CST 2021  9        10       Thu Jul 22 19:42:53 CST 2021  9        20
99f712c3-37c0-493c-b121-56e8511765f4  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 1h39m44s  err count                                                Thu Jul 22 19:44:33 CST 2021  10       10
4ef669f6-de6e-47e2-a088-a1238d0f7d43  image:resize                {"SourceURL":"https://example.com/myassets/image.jpg"}  in 1h42m25s  err count                                                Thu Jul 22 19:46:14 CST 2021  10       10
 
Originally created by @nkbai on GitHub (Jul 22, 2021). Original GitHub issue: https://github.com/hibiken/asynq/issues/299 Originally assigned to: @hibiken on GitHub. my asynq version is 0.18.2,but i cannot cancel tasks. ```txt asynq task ls --queue=default --state=retry ID Type Payload Next Retry Last Error Last Failed Retried Max Retry -- ---- ------- ---------- ---------- ----------- ------- --------- 99f712c3-37c0-493c-b121-56e8511765f4 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 2m25s err count Thu Jul 22 18:34:31 CST 2021 9 10 4ef669f6-de6e-47e2-a088-a1238d0f7d43 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 4m4s err count Thu Jul 22 18:34:31 CST 2021 9 10 5d06ccfc-4420-4bd9-b5ac-d60e66dae314 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 25m49s err count Thu Jul 22 18:59:25 CST 2021 9 10 ➜ asynq git:(master) asynq --version asynq version 0.18.2 ➜ asynq git:(master) asynq task cancel 99f712c3-37c0-493c-b121-56e8511765f4 Sent cancelation signal for task 99f712c3-37c0-493c-b121-56e8511765f4 ➜ asynq git:(master) asynq task ls --queue=default --state=retry ID Type Payload Next Retry Last Error Last Failed Retried Max Retry -- ---- ------- ---------- ---------- ----------- ------- --------- 5d06ccfc-4420-4bd9-b5ac-d60e66dae314 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 13m31s err count Thu Jul 22 18:59:25 CST 2021 9 10 Thu Jul 22 19:42:53 CST 2021 9 20 99f712c3-37c0-493c-b121-56e8511765f4 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 1h39m44s err count Thu Jul 22 19:44:33 CST 2021 10 10 4ef669f6-de6e-47e2-a088-a1238d0f7d43 image:resize {"SourceURL":"https://example.com/myassets/image.jpg"} in 1h42m25s err count Thu Jul 22 19:46:14 CST 2021 10 10 ```
kerem 2026-03-02 05:18:52 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@hibiken commented on GitHub (Jul 23, 2021):

Hi @nkbai thank you for creating this issue! I think this is a common misunderstanding.

In Asynq, cancel operation is applicable to only active tasks. It cancels currently processed tasks.
For pending, scheduled, retry tasks, you can either delete or archive task
Example:

# delete task
$ asynq task delete --queue=default --id=99f712c3-37c0-493c-b121-56e8511765f4

# archive task
$ asynq task archive --queue=default --id=99f712c3-37c0-493c-b121-56e8511765f4

Let me know if you have more questions :)

<!-- gh-comment-id:885362128 --> @hibiken commented on GitHub (Jul 23, 2021): Hi @nkbai thank you for creating this issue! I think this is a common misunderstanding. In Asynq, **cancel** operation is applicable to only **active** tasks. It cancels currently processed tasks. For *pending, scheduled, retry* tasks, you can either *delete* or *archive* task Example: ```sh # delete task $ asynq task delete --queue=default --id=99f712c3-37c0-493c-b121-56e8511765f4 # archive task $ asynq task archive --queue=default --id=99f712c3-37c0-493c-b121-56e8511765f4 ``` Let me know if you have more questions :)
Author
Owner

@nkbai commented on GitHub (Jul 24, 2021):

thanks very much

<!-- gh-comment-id:886053582 --> @nkbai commented on GitHub (Jul 24, 2021): thanks very much
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asynq#121
No description provided.