From: "ko1 (Koichi Sasada)" <noreply@...>
Date: 2021-12-02T20:59:42+00:00
Subject: [ruby-core:106419] [Ruby master Feature#18139] Add a method to stop/kill a Ractor from outside

Issue #18139 has been updated by ko1 (Koichi Sasada).

Status changed from Open to Rejected

Now Ractor is designed to "unexpected interruption free" (at least cross-ractor interruptions) so now it is not acceptable. Let's try without interrupts.

----------------------------------------
Feature #18139: Add a method to stop/kill a Ractor from outside
https://bugs.ruby-lang.org/issues/18139#change-95060

* Author: tagomoris (Satoshi TAGOMORI)
* Status: Rejected
* Priority: Normal
----------------------------------------
When a Ractor is doing I/O, it can'tf stop by itself (even when I/O is nonblock, IO.select will block).

```ruby
r = Ractor.new(listen) { |listen|
  while connection = listen.accept
    # process
  end
}

Signal.trap(:INT) { r.kill } # I want to do this
# or r.stop, r.interrupt
# or r.raise(MyStopSignalError)
```

If a Ractor's input is Ractor.receive only, it can stop itself when it receives a stop signal (via Ractor.receive). But the Ractor is doing I/O, it can't listen Ractor.receive. So there are no any channels to tell it should stop.
Under the current situation, we can only stop the entire runtime at once without any shutdown processes.

So, I want a method to kill or interrupt the Ractor, or to raise an exception in that Ractor from the outside.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>