[GH-ISSUE #599] [FEATURE REQUEST] Ability to abort send signal to stop task #2317

Open
opened 2026-03-15 20:04:01 +03:00 by kerem · 4 comments
Owner

Originally created by @surjit on GitHub (Jan 9, 2023).
Original GitHub issue: https://github.com/hibiken/asynq/issues/599

Originally assigned to: @hibiken on GitHub.

Is your feature request related to a problem? Please describe.
I have long running task which takes way long to complete. I found no way to cancel/abort those in-middle

Describe the solution you'd like
I want ability to cancel long running tasks. Currently job enqueue every time into redis, when I press cancel button on UI

Originally created by @surjit on GitHub (Jan 9, 2023). Original GitHub issue: https://github.com/hibiken/asynq/issues/599 Originally assigned to: @hibiken on GitHub. **Is your feature request related to a problem? Please describe.** I have long running task which takes way long to complete. I found no way to cancel/abort those in-middle **Describe the solution you'd like** I want ability to cancel long running tasks. Currently job enqueue every time into redis, when I press cancel button on UI
Author
Owner

@kamikazechaser commented on GitHub (Jan 16, 2023):

https://github.com/hibiken/asynq/wiki/Task-Timeout-and-Cancelation

<!-- gh-comment-id:1384354476 --> @kamikazechaser commented on GitHub (Jan 16, 2023): https://github.com/hibiken/asynq/wiki/Task-Timeout-and-Cancelation
Author
Owner

@surjit commented on GitHub (Jan 16, 2023):

@kamikazechaser It's not what I'm looking for. task cancellation on on-demand. with not specific time

<!-- gh-comment-id:1384437935 --> @surjit commented on GitHub (Jan 16, 2023): @kamikazechaser It's not what I'm looking for. task cancellation on on-demand. with not specific time
Author
Owner

@kamikazechaser commented on GitHub (Jan 17, 2023):

The Inspector does that for you. It is implied in the last CLI section of the wiki page. https://pkg.go.dev/github.com/hibiken/asynq#Inspector.CancelProcessing

<!-- gh-comment-id:1384890566 --> @kamikazechaser commented on GitHub (Jan 17, 2023): The Inspector does that for you. It is implied in the last CLI section of the wiki page. https://pkg.go.dev/github.com/hibiken/asynq#Inspector.CancelProcessing
Author
Owner

@safaci2000 commented on GitHub (Nov 2, 2023):

Can we add some documentation around that? I ended up putting all the pieces together but it'd be nice have some sample code.

Here's what I have.

var cancel context.CancelFunc = func() {
		inspector := asynq.NewInspector(redis.NewRedisClientStruct())
		err := inspector.CancelProcessing(info.ID)
		if err != nil {
			log.Error().Err(err).Msgf("failed to cancel task with ID: %s", info.ID)
		}
}

Your redis "Client' needs to implement: asynq.RedisConnOpt

<!-- gh-comment-id:1791249055 --> @safaci2000 commented on GitHub (Nov 2, 2023): Can we add some documentation around that? I ended up putting all the pieces together but it'd be nice have some sample code. Here's what I have. ```go var cancel context.CancelFunc = func() { inspector := asynq.NewInspector(redis.NewRedisClientStruct()) err := inspector.CancelProcessing(info.ID) if err != nil { log.Error().Err(err).Msgf("failed to cancel task with ID: %s", info.ID) } } ``` Your redis "Client' needs to implement: asynq.RedisConnOpt
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#2317
No description provided.