Skip Menu |

This queue is for tickets about the Time-Out CPAN distribution.

Report information
The Basics
Id: 84141
Status: open
Priority: 0/
Queue: Time-Out

People
Owner: Nobody in particular
Requestors: peter [...] morch.com
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 0.11
Fixed in: (no value)



Subject: Nested timeouts don't work with Time::HiRes
If Time::HiRes is loaded, nested timeouts don't work. Here is my test script: use strict; use warnings; use Time::Out qw(timeout) ; printf "Version: %s\n", $Time::Out::VERSION; timeout 3 => sub { timeout 1 => sub { sleep 3; } ; if ($@){ print "inner timeout\n"; } else { print "inner normal\n"; } sleep 5; } ; if ($@){ print "timeout\n"; } else { print "normal\n"; } And now two diffent runs: # One without Time::HiRes. This is what I expect: Show quoted text
> time perl -w timeout.pl
Version: 0.11 inner timeout timeout real 0m3.012s user 0m0.004s sys 0m0.008s # One with Time::HiRes. I still expect the outer timeout to time out, and I don't expect it to take 6+ seconds, just because Time::HiRes is loaded. Show quoted text
> time perl -MTime::HiRes -w timeout.pl
Version: 0.11 inner timeout normal real 0m6.021s user 0m0.012s sys 0m0.008s Tested on debian squeeze.
From: peter [...] morch.com
Now I did the investigation: This bug is a consequence of Bug #54196 for Time::HiRes: alarm and ularm return values are bogus https://rt.cpan.org/Public/Bug/Display.html?id=54196
On 2013-03-30 08:42:29, peter@morch.com wrote: Show quoted text
> Now I did the investigation: This bug is a consequence of > > Bug #54196 for Time::HiRes: alarm and ularm return values are bogus > https://rt.cpan.org/Public/Bug/Display.html?id=54196
So this is fixed in Time::HiRes 1.9721, it seems. Maybe importing Time::HiRes::alarm should happen only if Time::HiRes is not broken wrt alarm() (i.e. $Time::HiRes::VERSION < 1.9713 or $Time::HiRes::VERSION >= 1.9721 or so)? Regards, Slaven
On 2013-12-16 09:27:38, SREZIC wrote: Show quoted text
> On 2013-03-30 08:42:29, peter@morch.com wrote:
> > Now I did the investigation: This bug is a consequence of > > > > Bug #54196 for Time::HiRes: alarm and ularm return values are bogus > > https://rt.cpan.org/Public/Bug/Display.html?id=54196
> > So this is fixed in Time::HiRes 1.9721, it seems. Maybe importing > Time::HiRes::alarm should happen only if Time::HiRes is not broken wrt > alarm() (i.e. $Time::HiRes::VERSION < 1.9713 or $Time::HiRes::VERSION
> >= 1.9721 or so)?
>
Maybe there should be a test checking for correct operation, something like the below. And said this, maybe Time::Out should just require Time::HiRes 1.9721 as a minimum version, so users never stumble over this problem. #!perl use strict; use warnings; use Test::More; use Time::HiRes; use Time::Out qw(timeout); # Check for RT#54196, which possibly affects correct Time::Out operation for my $timeout (2148, 86400) { my $ret; timeout $timeout => sub { $ret = alarm(0); }; is $ret, $timeout or diag 'Probably may be fixed by upgrading Time::HiRes'; } done_testing; __END__