ruby-concurrency/concurrent-ruby

support re-raising exceptions when shutting down a timertask

grosser opened this issue · 4 comments

I want to use a timer-task to execute a heartbeat function while some other code is running
I was hoping shutdown would re-raise any exception that occurred inside the timer, but that seems to not be the case
I saw that an observer could do that, but it adds a lot of complexity.
It would be nice it a failed timer could re-raise it's exception when it's shut down without needed an observer, something like:

      task = Concurrent::TimerTask.execute(execution_interval: 10 * 60, run_now: true) do
        do_stuff
      end
      yield
    ensure
      task.shutdown reraise: true
    end
* Operating system:                mac
* Ruby implementation:             Ruby
* `concurrent-ruby` version:       1.1.10
* `concurrent-ruby-ext` installed: no
* `concurrent-ruby-edge` used:     no

How would that work if do_stuff is called multiple times and raises multiple times an exception?

Or stop at the first exception and wait for shutdown call

That's not compatible with the fault tolerance of https://ruby-concurrency.github.io/concurrent-ruby/master/Concurrent/TimerTask.html

Last exception could be possible, but is it so hard to use an Observer?
I'm not a big fan of adding complexity in the codebase if it can already be done reasonably simply another way.

yeah true, was mostly hoping it would be a good fit, thx for the details