[GH-ISSUE #520] How can I cancel task In My Code? #241

Closed
opened 2026-03-02 05:19:53 +03:00 by kerem · 3 comments
Owner

Originally created by @realmicro on GitHub (Jul 17, 2022).
Original GitHub issue: https://github.com/hibiken/asynq/issues/520

How can I cancel task In My Code?
If I enqueue a task like this:
client.Enqueue(task, asynq.ProcessIn(24*time.Hour))

Maybe I wanner cancel this task If this task not executed.
How Can I achieve this feature?

Originally created by @realmicro on GitHub (Jul 17, 2022). Original GitHub issue: https://github.com/hibiken/asynq/issues/520 How can I cancel task In My Code? If I enqueue a task like this: `client.Enqueue(task, asynq.ProcessIn(24*time.Hour))` Maybe I wanner cancel this task If this task not executed. How Can I achieve this feature?
kerem closed this issue 2026-03-02 05:19:53 +03:00
Author
Owner

@kienvtqhi commented on GitHub (Dec 19, 2022):

Hello,

Have you found out how to cancel a task?

<!-- gh-comment-id:1357008632 --> @kienvtqhi commented on GitHub (Dec 19, 2022): Hello, Have you found out how to cancel a task?
Author
Owner

@merulas commented on GitHub (May 14, 2024):

Help , same question

<!-- gh-comment-id:2110047343 --> @merulas commented on GitHub (May 14, 2024): Help , same question
Author
Owner

@fletcherist commented on GitHub (Sep 26, 2024):

Help , same question

@merulas @kienvtqhi

redisClientOpts := &asynq.RedisClientOpt{
	Addr:     redisOptions.Addr,
	Password: redisOptions.Password,
}
inspector := asynq.NewInspector(redisClientOpts)
err := inspector.CancelProcessing("taskId")
if err != nil {
	log.Error("task cancel failed: ", err)
	return err
}
<!-- gh-comment-id:2377007216 --> @fletcherist commented on GitHub (Sep 26, 2024): > Help , same question @merulas @kienvtqhi ```go redisClientOpts := &asynq.RedisClientOpt{ Addr: redisOptions.Addr, Password: redisOptions.Password, } inspector := asynq.NewInspector(redisClientOpts) err := inspector.CancelProcessing("taskId") if err != nil { log.Error("task cancel failed: ", err) return err } ```
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#241
No description provided.