in reply to Re: Splitting one large timeout into few smaller ones..
in thread Splitting one large timeout into few smaller ones..

Yeah, that would be exactly what I was asking about, I just hoped for something less dramatical (without die), but that's good enough, I can always wrap all that code in eval and just catch this 'die'.

Thanks.

Interestingly this works well with Event, I was affraid it wouldn't (Event uses timeout handling written in C, but it seems like it's alarm based). Here's the final code:

use Event; use Event::Stats; Event::Stats::enforce_max_callback_time(1); sub callback { for (1..int(rand(999))) { alarm(10); sleep 2;#relatively long running tast }; }; $Event::DIED = sub { Event::verbose_exception_handler(@_); Event::unloop_all(); }; # just die Event->idle(min=>1,max=>2,cb=> \&callback,max_cb_tm=>10,); Event::loop();