Skip to content

Conversation

@samuel-williams-shopify
Copy link
Contributor

@samuel-williams-shopify samuel-williams-shopify commented Feb 3, 2026

Fixes #49.

Types of Changes

  • Bug fix.
  • Breaking change.

Contribution

# $stderr.puts "Received TERM signal, terminating...", caller
::Thread.current.raise(Terminate)
# $stderr.puts "Received TERM signal, interrupting...", caller
::Thread.current.raise(Interrupt) # Same as SIGINT

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not change the rescue Terminate block instead of changing the raised exception?

Copy link
Contributor Author

@samuel-williams-shopify samuel-williams-shopify Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be possible, but Async itself specifically handles Interrupt differently from Terminate.

Interrupt triggers a graceful stop of the Async scheduler: https://github.com/socketry/async/blob/400bc2e1fedcaa72ae1fa86d5c8d7e1962c1f889/lib/async/scheduler.rb#L534-L543

I think we want to preserve this behaviour, and if we raised Terminate it would cause an ungraceful exit.

Later on, I think we can revisit this if necessary.

@ioquatix ioquatix merged commit e333ae5 into main Feb 4, 2026
40 of 48 checks passed
@ioquatix ioquatix deleted the graceful-terminate branch February 4, 2026 04:00
@ioquatix ioquatix added this to the v0.30.0 milestone Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graceful shutdown on kubernetes

4 participants