Skip to content

Add support for stop(cause:). #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add support for stop(cause:). #388

wants to merge 1 commit into from

Conversation

ioquatix
Copy link
Member

@ioquatix ioquatix commented May 16, 2025

Add cause: to Async::Task#stop(cause:) so that extra information about the reason for stopping can be provided. It must be an exception suitable for raise Async::Stop, cause: cause.

Types of Changes

  • New feature.

Contribution

@ioquatix ioquatix force-pushed the async-stop-cause branch 2 times, most recently from 2be7af1 to 1aee925 Compare May 16, 2025 05:19
@ioquatix ioquatix force-pushed the async-stop-cause branch from 1aee925 to 53670d1 Compare May 16, 2025 05:25
@ioquatix
Copy link
Member Author

I found an issue, Fiber#raise does not seem to support cause: keyword argument correctly. I need to investigate.

@macournoyer
Copy link

I test w/ a sleep, and sending SIGINT to the worker sleeping. Here's what I got:

Async::Stop: {cause: #<Async::Stop: {cause: #<Async::Stop: {cause: #<Async::Stop: {cause: #<Interrupt: Interrupt>}>}>}>}
/Users/ma/.gem/ruby/3.4.4/bundler/gems/async-53670d16cb43/lib/async/scheduler.rb:221:in 'IO::Event::Selector::KQueue#transfer'
	/Users/ma/.gem/ruby/3.4.4/bundler/gems/async-53670d16cb43/lib/async/scheduler.rb:221:in 'Async::Scheduler#block'
	/Users/ma/.gem/ruby/3.4.4/bundler/gems/async-53670d16cb43/lib/async/scheduler.rb:254:in 'Async::Scheduler#kernel_sleep'

Seems there is too much nesting.

@ioquatix
Copy link
Member Author

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.

2 participants