Skip Menu |
 

This queue is for tickets about the IO-Async CPAN distribution.

Report information
The Basics
Id: 127835
Status: open
Priority: 0/
Queue: IO-Async

People
Owner: Nobody in particular
Requestors: DBOOK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Global loop exception handling
Download (untitled) / with headers
text/plain 288b
There's currently no way to add exception handling to all loop callbacks in order to prevent the loop being stopped by an exception. A possible method would be to allow an on_error event handler to be specified for the loop, and if unspecified this would fallback to the current behavior.
Download (untitled) / with headers
text/plain 560b
On Wed Nov 28 18:07:25 2018, DBOOK wrote: Show quoted text
> There's currently no way to add exception handling to all loop > callbacks in order to prevent the loop being stopped by an exception. > A possible method would be to allow an on_error event handler to be > specified for the loop, and if unspecified this would fallback to the > current behavior.
(as discussed on IRC:) Yes this sounds useful behaviour. Probably the way forward is to add a `->configure` method to IO::Async::Loop (and while we're there, migrate the `set_resolver` ability to it) -- Paul Evans
Download (untitled) / with headers
text/plain 114b
$loop->configure( on_exception => sub { ... } ); Still need to design what arguments it receives -- Paul Evans
Download (untitled) / with headers
text/plain 971b
Prior art for posterity: POE - exceptions send a fake 'DIE' signal to the kernel, which can be handled by a session and is passed several arguments pertaining to the state of the kernel when the exception occurred. If CATCH_EXCEPTIONS is disabled, events are not run in an eval. https://metacpan.org/pod/POE::Kernel#Exception-Handling EV - exceptions are passed to $EV::DIED, a global coderef which defaults to warning "EV: error in callback (ignoring): $@" and uses $@ directly. Events are always run in an eval and exceptions in $EV::DIED are ignored. https://metacpan.org/pod/EV#$EV::DIED Mojo::IOLoop - exceptions emit an error event on the Mojo::Reactor of "$what failed: $@" - where $what is a brief label of the handler that failed. Error event is fatal by default on its own but Mojo::IOLoop sets up a handler that warns "$reactor_class: $exception" instead. I think that the Mojo::IOLoop strategy is most similar to a reasonable approach for IO::Async::Loop.
Download (untitled) / with headers
text/plain 446b
On Mon Apr 15 16:07:01 2019, DBOOK wrote: Show quoted text
> Mojo::IOLoop - exceptions emit an error event on the Mojo::Reactor of > "$what failed: $@" - where $what is a brief label of the handler that > failed. Error event is fatal by default on its own but Mojo::IOLoop > sets up a handler that warns "$reactor_class: $exception" instead.
Addendum: events are always run in an eval, and the relevant documentation: https://metacpan.org/pod/Mojo::Reactor#error


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.