Skip to content

Commit

Permalink
The shutdown timeout is ignored if the ctx passed to the processor is…
Browse files Browse the repository at this point in the history
… canceled.

The processorCtx must not inherit from the passed ctx, because in that case both
are canceled together, not giving the shutdown timer time to run.
  • Loading branch information
bojanz committed Apr 23, 2024
1 parent 9f736f1 commit 4d27f8a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nanoq.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (p *Processor) Handle(taskType string, h Handler, ms ...Middleware) {
// The tasks that are still being processed are then given until shutdownTimeout to complete,
// after which they are stopped (via canceled context).
func (p *Processor) Run(ctx context.Context, concurrency int, shutdownTimeout time.Duration) {
processorCtx, cancel := context.WithCancelCause(ctx)
processorCtx, cancel := context.WithCancelCause(context.Background())
go func() {
shutdownCh := make(chan os.Signal, 1)
signal.Notify(shutdownCh, os.Interrupt, syscall.SIGTERM)
Expand Down

0 comments on commit 4d27f8a

Please sign in to comment.