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

Supply .throttle hangs/wrong results #5562

Open
p6rt opened this issue Aug 12, 2016 · 2 comments
Open

Supply .throttle hangs/wrong results #5562

p6rt opened this issue Aug 12, 2016 · 2 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 12, 2016

Migrated from rt.perl.org#128906 (status was 'new')

Searchable as RT128906$

@p6rt
Copy link
Author

p6rt commented Aug 12, 2016

From liukan@360.cn

As shown below, of the 3 consecutive times the following code was run, 2 hung.
the results produced didn't make sense either, unless I misunderstood how throttle should work.

8< ======================= 8<

use v6;

my $s = Supply.from-list(^6);
my $t = $s.throttle​: 3, { sleep 3; $_ };

$t.act​: -> $v { $v.result.say };
$t.wait

8< ======================= 8<

liukan@​candor​:~/Code$ time perl6 foo
0
1
2
3
4
5
0

real 0m6.188s
user 0m0.160s
sys 0m0.036s
liukan@​candor​:~/Code$ time perl6 foo
0
1
2
3
4
5
1
^C

real 0m33.380s
user 0m0.128s
sys 0m0.012s
liukan@​candor​:~/Code$ time perl6 foo
2
0
3
4
5
0
^C

real 0m33.155s
user 0m0.128s
sys 0m0.032s
liukan@​candor​:~/Code$

liukan@​candor​:~/Code$ perl6 -v
This is Rakudo version 2016.07.1 built on MoarVM version 2016.07
implementing Perl 6.c.

liukan@​candor​:~/Code$ uname -a
Linux candor 4.4.0-34-generic #​53-Ubuntu SMP Wed Jul 27 16​:06​:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

@p6rt
Copy link
Author

p6rt commented Aug 12, 2016

From liukan@360.cn

[15​:01] <kanl> Supply . throttle returns a supply of promises. How does each promise correspond to the original items? e.g. my $s = Supply.from-list( |@​a ).throttle​: 3, -> $v { do-something-with( $a ) }; $s.tap​: -> $v { how-to-figure-out-relation-here() }
[15​:04] <kanl> this matters because when running a number of things in parallel, one supposedly would need to know whose promise got kept and whose got broken, not just which.
[15​:15] <kanl> i don't suppose it's safe to stick things into a hash inside throttle's pointy block, not knowing it's act() or tap(), Someone care to share, please?
[15​:17] == sssd [~ac1f0106@​38.72.195.196] has quit [Quit​: http://www.kiwiirc.com/ - A hand-crafted IRC client]
[15​:20] <kanl> m​: my $s = Supply.from-list(^6).throttle​: 3, { sleep 3; die if $_ == 1 }; $s.act​: -> $v { $v.status.say }; $s.wait;
[15​:20] <+camelia> rakudo-moar c587b9​: OUTPUT«Keptâ�¤Brokenâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Memory allocation failed; could not allocate 4 bytesâ�¤Â»
[15​:21] <kanl> m​: my $s = Supply.from-list(^6).throttle​: 3, { sleep 3; die if $_ == 1 }; $s.act​: -> $v { $v.status.say }; $s.wait;
[15​:21] <+camelia> rakudo-moar c587b9​: OUTPUT«Brokenâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Memory allocation failed; could not allocate 32 bytesâ�¤Memory allocation failed; could not allocate 4 bytesâ�¤Â»
[15​:21] <kanl> m​: my $s = Supply.from-list(^6).throttle​: 3, { sleep 3; die if $_ == 1 }; $s.act​: -> $v { $v.status.say }; $s.wait;
[15​:21] <+camelia> rakudo-moar c587b9​: OUTPUT«Keptâ�¤Brokenâ�¤Keptâ�¤Keptâ�¤Memory allocation failed; could not allocate 4 bytesâ�¤Â»
[15​:22] == TheLemonMan [~root@​unaffiliated/thelemonman] has joined #perl6
[15​:22] <kanl> The same code produces weirder results on my machine.
[15​:24] == labster [~Adium@​miraheze/Labster] has joined #perl6
[15​:25] <gfldex> m​: my $s = Supply.from-list(^6).throttle​: 3, { sleep 3; Failure.new("booboo") if $_ == 1 }; $s.act​: { .status.say }; $s.wait;
[15​:25] <+camelia> rakudo-moar c587b9​: OUTPUT«Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Â»
[15​:25] == camelia [~p6eval@​ns1.niner.name]
[15​:25] == realname : combined, experimental evalbot
[15​:25] == channels : +#perl6
[15​:25] == server : leguin.freenode.net [UmeÃ¥, SE, EU]
[15​:25] == account : camelia
[15​:25] == End of WHOIS
[15​:25] <gfldex> m​: my $s = Supply.from-list(^6).throttle​: 3, { sleep 3; Failure.new("booboo") if $_ == 1 }; $s.act​: { .status.say }; $s.wait;
[15​:25] <+camelia> rakudo-moar c587b9​: OUTPUT«Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Keptâ�¤Memory allocation failed; could not allocate 32 bytesâ�¤Â»
[15​:26] <gfldex> nice new bug for jnthn :)
________________________________
[15​:29] == darutoko [~Vandal@​176.209.234.142] has joined #perl6
[15​:31] == wbill [~wbill@​96-38-107-68.dhcp.jcsn.tn.charter.com] has joined #perl6
[15​:31] <kanl> even if said bug is fixed, i still have no way of knowing the broken promise belongs to 1.
[15​:32] <kanl> well, i do, because i put it there. but if i didn't, then how?

- kan

@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