Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Splitting one large timeout into few smaller ones..

by Eyck (Priest)
on Apr 07, 2005 at 20:10 UTC ( [id://445864]=note: print w/replies, xml ) Need Help??


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();

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://445864]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2024-04-26 07:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found