New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
await on a Supply .head .Promise never fires (but Supplier.head.Promise does) #4824
Comments
From @skids16:18 skids I think the Supply work may have made $fh.watch.Promise not fire anymore. These work: $ perl6 -e 'my $f = Supplier.new; my $s = $f.head(1).Supply; my $t = $s.tap(-> $ { 42.say }, done => {43.say} ); start { for 0..3 { $f.emit(42) }; $f.done(); }; await $s.Promise; 44.say; ' $ perl6 -e 'my $f = Supplier.new; my $s = $f.head(1).Supply; my $t = $s.tap(-> $ { 42.say }, done => {43.say} ); start { for 0..3 { $f.emit(42) }; }; await $s.Promise; 44.say; ' This neither sends a done nor fulfills a .Promise (input echoed into file from another terminal): $ perl6 -e 'my $fh = open("/tmp/foo.txt", :create); my $s = $fh.watch.head(1); my $t = $s.tap(-> $ { 42.say }, done => {43.say} ); await $s.Promise; 44.say' ...and when the .head is off a Supply instead of a Supplier, a done from the original Supply propagates but the Promise never unhooks: $ perl6 -e 'my $f = Supplier.new; my $s = $f.Supply.head(1); my $t = $s.tap(-> $ { 42.say }, done => {43.say} ); start { for 0..3 { $f.emit(42) }; $f.done(); }; await $s.Promise; 44.say; ' $ perl6 -e 'my $f = Supplier.new; my $s = $f.Supply.head(1); my $t = $s.tap(-> $ { 42.say }, done => {43.say} ); start { for 0..3 { $f.emit(42) }; }; await $s.Promise; 44.say; ' |
From @jnthnOn Sat Dec 05 11:13:54 2015, bri@abrij.org wrote:
This works reliably now, and so could do with a test. Probably thanks to one of the many Supply fixes over the last months.
This code is vulnerable to a race condition, thus it sometimes works, sometimes not. If you add a `sleep 1` before the `await` then it reliably hangs. The reason is that a Supplier is a live supply; if you miss the events (emit/done) then they're gone for good. (Note that `.Promise` taps the supply separately from the `.tap` that is already taking place.) For this to reliably work, the `Promise` should be obtained prior to setting off the `start` block. This works reliably, every time: my $f = Supplier.new; Tagging testneeded for the part that deserves a test. /jnthn |
The RT System itself - Status changed from 'new' to 'open' |
From @moritzTests now in https://rt-archive.perl.org/perl6//Public/Bug/Display.html?id=126824 |
@moritz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#126824 (status was 'resolved')
Searchable as RT126824$
The text was updated successfully, but these errors were encountered: