Subject: | needs_all cancels subfutures on failure, even if they have other actions pending |
Date: | Thu, 24 Aug 2017 23:30:53 +0100 |
To: | bug-future [...] rt.cpan.org |
From: | Richard van der Hoff <richard [...] matrix.org> |
Suppose I have two inputs, A and B. Once A completes, I want to do C.
Once A *and* B complete, I want to do D.
But what if B fails? I still want to do C when A completes. Basically, I
expect the following code to print "a done", and it doesn't.
use Future;
my $future_a = Future->new;
my $future_b = Future->new;
$future_a -> on_done(sub { print "a done\n"; });
my $future_d = Future->needs_all($future_a, $future_b);
$future_b->fail("foo");
$future_a->done("bar");
The problem is of course that needs_all is cancelling the input futures.
This seems like a dangerous thing to do.
(perl v5.22.1, Future 0.35)