Skip Menu |

This queue is for tickets about the future CPAN distribution.

Report information
The Basics
Id: 122892
Status: open
Priority: 0/
Queue: future

People
Owner: Nobody in particular
Requestors: richard [...] matrix.org
Cc:
AdminCc:

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



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)
See https://rt.cpan.org/Ticket/Display.html?id=96685 for more details, but the step you're missing here is the ->without_cancel method: 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(map $_->without_cancel, $future_a, $future_b); $future_b->fail("foo"); $future_a->done("bar"); cheers, Tom On 2017-08-24 23:37:40, richard@matrix.org wrote: Show quoted text
> 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)