Eyck has asked for the wisdom of the Perl Monks concerning the following question:
{ local $SIG{ALRM} = sub { die "alarm timeout" }; alarm $timeout; # Here goes the code that can hang, #for example network connections die $@ if $@ && $@ !~ /alarm timeout/; }
Unfortunatelly this doesn't work that well, especially if you're trying to be generic and you've got no control over the block to protect - this block affects the code inside, for example sleep start behaving erradically, if the code inside rewrites DIE subroutine you can also get in trobule..etc.
I started using Event module, which defines it's own method for timeing out, (they put it in Event::Stats, which is like the first place I would look for it...), but the module is written in C and so is it's timeout ...AFAIK.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Reliable Timeout
by gaal (Parson) on Feb 14, 2005 at 13:27 UTC | |
by lidden (Curate) on Feb 14, 2005 at 20:59 UTC | |
by gaal (Parson) on Feb 15, 2005 at 07:30 UTC | |
|
Re: Reliable Timeout
by sh1tn (Priest) on Feb 14, 2005 at 17:05 UTC | |
by Eyck (Priest) on Feb 15, 2005 at 06:17 UTC | |
by bluto (Curate) on Feb 15, 2005 at 19:06 UTC | |
by Eyck (Priest) on Feb 16, 2005 at 09:01 UTC | |
by bluto (Curate) on Feb 16, 2005 at 16:55 UTC |