cpan-authors / IPC-Run

https://metacpan.org/pod/IPC::Run
Other
21 stars 38 forks source link

timeout causes delay with output not captured [rt.cpan.org #57277] #83

Closed toddr closed 6 years ago

toddr commented 7 years ago

Migrated from rt.cpan.org#57277 (status was 'open')

Requestors:

Attachments:

From ncleaton@cpan.org on 2010-05-07 09:16:16:

If I run a command that does not exit right away with a timeout and
without capturing either stdout or stderr, then IPC::Run appears to wait
for the timeout even if the command finishes sooner:

# This takes 10 seconds, should only take 1 second
run ['perl', '-e', 'sleep 1'], \undef, \*STDOUT, \*STDERR, timeout(10);

Tested against 0.89.  Capturing either STDOUT or STDERR to a string
buffer or replacing the command with one that exits right away
eliminates the problem.

Nick

From ncleaton@cpan.org on 2010-05-11 18:23:41:

On Fri May 07 05:16:16 2010, NCLEATON wrote:
> If I run a command that does not exit right away with a timeout and
> without capturing either stdout or stderr, then IPC::Run appears to wait
> for the timeout even if the command finishes sooner:
> 
> 
> # This takes 10 seconds, should only take 1 second
> run ['perl', '-e', 'sleep 1'], \undef, \*STDOUT, \*STDERR, timeout(10);

Patch attached.

From engstrom+bitcard@mtu.net on 2010-05-12 02:31:07:

On Fri May 07 05:16:16 2010, NCLEATON wrote:
> If I run a command that does not exit right away with a timeout and
> without capturing either stdout or stderr, then IPC::Run appears to
> wait for the timeout even if the command finishes sooner:
> 
> # This takes 10 seconds, should only take 1 second
> run ['perl', '-e', 'sleep 1'], \undef, \*STDOUT, \*STDERR, timeout(10);

I can confirm this (pre suggested patch, on Mac OS X 10.6.3, Perl
5.8.9).  I also see the same behavior with output sent to a file, as in:
  run ["perl", "-e", "sleep 2"], \undef, "&>", "/tmp/foo", timeout(10);'

However, I've found two workarounds:
 1. use an empty string for input:
   run ["perl", "-e", "sleep 2"], "", "&>", "/tmp/foo", timeout(10);'
 2. use a subroutine for output:
   run ["perl", "-e", "sleep 2"], \undef, "&>", sub {print @_},
timeout(10);'

Regarding the suggested patch, I'm not convinced that is the right
approach.  Yes, it works, but it will cause the _select_loop to
_ALWAYS_ use a minimal (sub-second) timeout, if I read the code
correctly.  

I also note that the comments to pumpable indicate that it should
sometimes return a value > 0, but the code will never do that.

I will defer to those who know the code-base better, as I've only been
perusing it for today.

From toddr@cpan.org on 2010-05-14 04:58:06:

So, The suggested work around just ignores the use of select with a timeout. Looking closer at 
this, I think the design might be fundamentally wrong for how this works. Looking back in the 
code, it's been this way since it's inception. I'll have to look at it closer later. I don't have a quick 
fix at the moment and I agree that the patch isn't really the right one. 

I will add the patch for the test since This should have been in the test suite from the beginning. 
Thanks!

From toddr@cpan.org on 2011-07-01 04:30:41:

The test is now shipped as a TODO.

From ribasushi@leporine.io on 2012-01-11 00:14:24:

Any outlook on having this fixed? Cheers!

From toddr@cpan.org on 2012-01-16 07:37:19:

On Tue Jan 10 19:14:24 2012, RIBASUSHI wrote:
> Any outlook on having this fixed? Cheers!

I've put a dev release out with just this one change. Let's see how it performs on all platforms.

From ribasushi@leporine.io on 2012-02-14 09:46:57:

On Mon Jan 16 02:37:19 2012, TODDR wrote:
> On Tue Jan 10 19:14:24 2012, RIBASUSHI wrote:
> > Any outlook on having this fixed? Cheers!
> 
> I've put a dev release out with just this one change. Let's see how it
> performs on all platforms.

As per IRC:

<ribasushi> toddr: on IPC::Run - you have all green, including a win32
and a cygwin that rurban just sent out like 30 secs ago. The two fails
are both from BSD's clock sucking in a VM (reap takes way too long -
perhaps up the timer?)
<ribasushi> toddr: can haz IPC::Run released proper? :)

Reini Urban said he smoked the devrel on everything he had and got all
green as well.

http://matrix.cpantesters.org/?dist=IPC-Run%200.91_01

From toddr@cpan.org on 2012-02-15 05:07:15:

0.91 released to CPAN

From cpanrt@edsantiago.com on 2012-10-18 20:23:30:

On Tue May 11 22:31:07 2010, engstrom wrote:
> I also note that the comments to pumpable indicate that it should
> sometimes return a value > 0, but the code will never do that.

See RT#68859 comment 1 (18 Oct 2012) For a different approach that could 
work better for long timeouts (less polling).

From cpanrt@edsantiago.com on 2012-10-18 20:25:46:

Argh. Sorry. RT told me I could reply while leaving the ticket resolved. 
Let's see if I can force it back.
toddr commented 6 years ago

This was resolved in v0.91