Skip to content
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

done() on first entry to whenever block does not exit react {} #5398

Closed
p6rt opened this issue Jun 23, 2016 · 9 comments
Closed

done() on first entry to whenever block does not exit react {} #5398

p6rt opened this issue Jun 23, 2016 · 9 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Jun 23, 2016

Migrated from rt.perl.org#128469 (status was 'resolved')

Searchable as RT128469$

@p6rt
Copy link
Author

p6rt commented Jan 29, 2016

From @jonathanstowe

Hi,
I was investigating some problem I was having with my own code and came upon this.

It appears that "done" in a whenever block in a react does not actually exit the react.

  react { whenever Supply.interval(1) -> $v { say "done"; done(); }; }

will print "done" but not exit, although it would appear that the processing of other whenever blocks is blocked.

If however the "done" is protect by a comparison against the value passed to the block then it does work as expected​:

  react { whenever Supply.interval(2) -> $v { if $v == 2 {say "done"; done(); } }; whenever Supply.interval(1) { say "tick"}}
  tick
  tick
  tick
  tick
  done

And then exits the react. However if the block is protected by some other condition (that doesn't check the value supplied to the block,) then it doesn't exit the react​:

  react { whenever Supply.interval(3) -> $v { if 1 == 1 {say "done"; done(); } }; whenever Supply.interval(1) { say "tick"}}

It appears to execute the block immediately, terminate the other whenever and not exit the loop.

Interestingly also if

  react { whenever Supply.interval(3) -> $v { if Bool.pick {say "done"; done(); } }; whenever Supply.interval(1) { say "tick"}}

picks True first it doesn't exit but does it at least one "tick" block is executed. So it would appear (can you tell that I am finding more weirdness the harder I look :) that if it calls "done" on the time of its first execution then the done doesn't work correctly. This would militate against using an externally controlled Promise to execute a done for example.

I'm guessing that this is tricky to test but something like​:

  my $p = Promise.new;
  my $q = start {
  react { whenever $p { say " done"; done; } };
  True
  };
  $p.keep;
  sleep 1;
  say $q.status;

May help somewhat.

It can all be worked around but I am sure it's not the intended behaviour.

This is with the

This is Rakudo version 2015.12-225-g7801920 built on MoarVM version 2015.12-29-g8079ca5
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Jun 23, 2016

From @skaji

I'm trying examples in https://doc.perl6.org/language/concurrency

Then I find
$ perl6 -e 'react { whenever Supply.interval(1) -> $v { say $v; done() if $v == 4 } }'
works, but
$ perl6 -e 'react { whenever Supply.interval(1) -> $v { say $v; done() if $v == 0 } }'
freezes.

Simpler example which freezes is​:
$ perl6 -e 'react { whenever Supply.interval(1) { done(); } }'

My perl version is​:
$ perl6 -v
This is Rakudo version 2016.06-22-g09cc2fb built on MoarVM version 2016.06
implementing Perl 6.c.

@p6rt
Copy link
Author

p6rt commented Jul 13, 2016

From @zoffixznet

Did a bit more experimenting, it seems to freeze only SOME of the time​:

zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: 1 { say "Run $_"; done } }'
Run 0
^C
zoffix@​VirtualBox​:~$ perl6 -v
This is Rakudo version 2016.06-154-g55c359e built on MoarVM version 2016.06-9-g8fc21d5
implementing Perl 6.c.
zoffix@​VirtualBox​:~$

But doesn't ever freeze if done is called non-first run, even if I set a tiny delay between intervals​:

zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: .01 { say "Run $_"; done if $_ >= 1 } }'
Run 0
Run 1
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: .01 { say "Run $_"; done if $_ >= 1 } }'
Run 0
Run 1
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: .01 { say "Run $_"; done if $_ >= 1 } }'
Run 0
Run 1
zoffix@​VirtualBox​:~$ perl6 -e 'react { whenever Supply.interval​: .01 { say "Run $_"; done if $_ >= 1 } }'
Run 0
Run 1

@p6rt
Copy link
Author

p6rt commented Jul 13, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Jul 14, 2016

From @zoffixznet

♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥
🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁

Skip-fudge added in Raku/roast@a047d78ac9

🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁🏁
♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥♥

@p6rt
Copy link
Author

p6rt commented Sep 7, 2016

From @zoffixznet

This now appears to have been fixed by some of the recent async fixes.

Tests now pass and have been unfudged in Raku/roast@92951b39ee

@p6rt
Copy link
Author

p6rt commented Sep 8, 2016

From @skaji

```
$ perl6 -v
This is Rakudo version 2016.08.1-130-ga62207e built on MoarVM version 2016.08-43-g3d04391
implementing Perl 6.c.

$ perl6 -e 'react { whenever Supply.interval(1) -> $v { say $v; done() if $v == 0 } }; say "exit"'
0
exit
```
:+1​:

On Wed Sep 07 10​:40​:14 2016, cpan@​zoffix.com wrote​:

This now appears to have been fixed by some of the recent async fixes.

Tests now pass and have been unfudged in
Raku/roast@92951b39ee

@p6rt
Copy link
Author

p6rt commented Sep 12, 2016

From @jonathanstowe

Yep,
Just confirmed here with all the original examples I gave, all good.

Now to remember where it was I had hacked round this :-\

On Wed, 2016-09-07 at 10​:40 -0700, Zoffix Znet via RT wrote​:

This now appears to have been fixed by some of the recent async
fixes.

Tests now pass and have been unfudged in https://github.com/perl6/roa
st/commit/92951b39ee

@p6rt
Copy link
Author

p6rt commented Dec 18, 2016

@zoffixznet - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Dec 18, 2016
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant