Open tadegenban opened 7 years ago
This seems to happen if the child takes more than 120 seconds to finish. I think Windows is closing the socket connection used by IO::Pipely due to inactivity.
Another test script to demonstrate the pipe will not keep-alive on windows, and closed after 120s
use strict; use warnings; use 5.012; use IO::Pipely 'pipely';
my ($uni_read, $uni_write) = pipely(type => 'inet'); my $n = 1; while ( $n < 130 ) {
sleep 1;
$n++;
}
print $uni_write "whee inet\n"; my $uni_input = <$uni_read>; chomp $uni_input; say $uni_input;
doesn't that second example show that the problem is not in ForkCall but in windows? It is unfortunate but I'm not sure what could be done to prevent it.
A workaround might be to use socketpairly() instead of pipely() and then have the parent keep-alive using its side of the "pipe".
use strict; use warnings; use 5.012; use Mojo::IOLoop::ForkCall;
my $fork = Mojo::IOLoop::ForkCall->new; $fork->run(sub { sleep 200;return 'success' }, [], sub { my ( $fork, $err, @ret) = @_; say $err if $err; say @ret;} );
$fork->ioloop->start;
======== run this test script on Windows, I will got : an existing connection was forcibly closed by the remote host. at lib/perl5/Mojo/IOLoop/ForkCall.pm line 132
But If I set sleep 200 to => sleep 20, it's will be OK