Perl-Sensitive Sunglasses | |
PerlMonks |
Splitting one large timeout into few smaller ones..by Eyck (Priest) |
on Apr 07, 2005 at 14:12 UTC ( [id://445681]=perlquestion: print w/replies, xml ) | Need Help?? |
Eyck has asked for the wisdom of the Perl Monks concerning the following question:
Here's the situation - I'm using Event, and am using it's timeout feature (Event::Stats).
However, the procedure that's beeing watched contains variable number of steps, logically this goes like this
Taks that could hang include 'do_one_task' and 'foreach'. Each step should finish in under 20 seconds, but because there are up to 100 of steps involved, I need to set unreasonably large timeout value, like 2000 seconds for the whole subroutine. This is bad because every single step can go into infinite loop, I should be able to detect this in under 30 seconds, and because I'm using aggegate values I won't know about the job hanging until 2000 seconds later. I would like to split one big timeout value for this whole code block, into few smaller ones, essentially this means that I would like to convert this code into something like this: Alternatively I would need to use something like coroutines, but I think this would be way beyond my skill, ie: where mysubroutine would recall the place where it last finished, ie Which approach is the best (and I'm not sure if this coroutine-like solution is at all possible with perl)? update
Back to
Seekers of Perl Wisdom
|
|