Front page | perl.perl6.users |
Postings from April 2022
Re: Help with promises, supplies and channels.
Thread Previous
|
Thread Next
From:
Elizabeth Mattijsen
Date:
April 7, 2022 10:25
Subject:
Re: Help with promises, supplies and channels.
Message ID:
E952C0AE-13D6-48A4-A342-08AA12E70E81@dijkmat.nl
Fixed with https://github.com/rakudo/rakudo/commit/5658f4da07b44d492a3d35d57fa76939822d2c66
Thanks for the report!
> On 7 Apr 2022, at 11:28, David Emanuel da Costa Santiago <demanuel@gmail.com> wrote:
>
>
> Thanks for the information!
>
> I opened a bug in rakudo:
>
> https://github.com/rakudo/rakudo/issues/4853
>
>
> Regards,
> David Santiago
>
>
> Às 05:27 de 07/04/22, yary escreveu:
>> For what it's worth, I'm on a mac, promise_test.raku hangs for me once in a while also.
>> Welcome to Rakudo(tm) v2021.04.
>> Implementing the Raku(tm) programming language v6.d.
>> Built on MoarVM version 2021.04.
>> Trying to reduce it, I would like to find a program that reliably tickles this bug and hangs every time... this variation does not crash for me (I ran it 100x)
>> ### close_much.raku ###
>> my Channel $ch .= new;
>> my @proms = (1..2000).map: {
>> start react {
>> whenever $ch.closed { done }
>> }
>> };
>> $ch.close;
>> await Promise.allof(@proms);
>> say $*VM;
>> ###
>> this does not crash for me
>> ### supply_to_many.raku ###
>> my Channel $ch .= new;
>> my $p1 = Supply.interval(3);
>> my @proms = (1..2000).map: {
>> start react {
>> whenever $p1 { $ch.close }
>> whenever $ch.closed { done }
>> }
>> };
>> await Promise.allof(@proms);
>> say $*VM;
>> ###
>> This gives a sensible error "Cannot send a message on a closed channel"
>> ### close_then_send.raku ###
>> my Channel $ch .= new;
>> # Close first, send next
>> $ch.close;
>> $ch.send("Hi!");
>> ###
>> This does not crash for me, for different combinations of $senders & $receivers (1000,1) (1,1000) (1000,1000)
>> ### config_send_recv.raku ###
>> my Channel $ch .= new;
>> my Supply $p1 .= interval(1);
>> my ($senders, $receivers) = (2000,2);
>> my Int $count = 0;
>> my @sends = (1..$senders).map: {
>> start react {
>> whenever $p1 -> $interval {
>> $ch.send($_);
>> $ch.close if ++$count == $senders;
>> }
>> whenever $ch.closed { done }
>> }
>> };
>> my @proms = (1..$receivers).map: {
>> start react {
>> whenever $ch.closed {
>> done;
>> }
>> whenever $ch -> $data {
>> print "$_=$data|";
>> }
>> }
>> };
>> await Promise.allof(@proms,@sends);
>> say $*VM;
>> ###
>> I didn't succeed - fun to try!
>> -y
>> On Tue, Apr 5, 2022 at 3:55 PM William Michels via perl6-users <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:
>> Thanks for the bash loop. I'm seeing a few hangs, also some errors
>> returned saying:
>> "Unhandled exception in code scheduled on thread 4"
>> (MacOS 11.11)
>> On Tue, Apr 5, 2022 at 12:47 PM David Emanuel da Costa Santiago
>> <demanuel@gmail.com <mailto:demanuel@gmail.com>> wrote:
>> Hi William,
>> when it fails or hangs it doesn't print the last line.
>> Please check attached file for output of the stack.
>> Since the failures are random, it's easier to invoke it in a loop:
>> bash$ for i in $(seq 100); do raku test.raku; done
>> If nothing is wrong with the code, i'll open a bug in the github.
>> Regards,
>> David Santiago
>> Às 21:37 de 05/04/22, William Michels escreveu:
>> > No problems so far.
>> >
>> > say $*VM; #add as last line, returns:
>> > moar (2021.06)
>> >
>> > On Tue, Apr 5, 2022 at 11:06 AM David Emanuel da Costa Santiago
>> > <demanuel@gmail.com <mailto:demanuel@gmail.com>
>> <mailto:demanuel@gmail.com <mailto:demanuel@gmail.com>>> wrote:
>> >
>> > Hi,
>> >
>> >
>> >
>> > I'm trying to learn about promises, supplies and
>> channels. So i made
>> > this code:
>> >
>> > """
>> >
>> > my $p1 = Supply.interval(5);
>> > my $p2 = Supply.interval(2);
>> > my Channel $ch = Channel.new;
>> >
>> > my $prom = start react {
>> > whenever $p1 -> $interval {
>> > say "5";
>> > }
>> >
>> > whenever $p2 -> $interval {
>> > say 2;
>> > }
>> >
>> > whenever $ch.closed {
>> > done;
>> > }
>> >
>> > whenever $ch -> $data {
>> > say "Data: $data";
>> > }
>> > }
>> >
>> > my $prom2 = start react {
>> > whenever $p1 -> $interval {
>> > $ch.send("5.2");
>> > $ch.close;
>> > }
>> > whenever $ch.closed {
>> > done;
>> > }
>> > }
>> >
>> > my @proms = ($prom, $prom2);
>> > await Promise.allof(@proms);
>> >
>> > """
>> >
>> >
>> >
>> > I don't see anything wrong with this but most of the
>> times runs fine,
>> > sometimes hangs, sometimes throw exception. Am i doing
>> something that i
>> > shouldn't be doing?
>> >
>> > $ raku --version
>> > Welcome to Rakudo™ v2022.03-130-g8f7cc0847.
>> > Implementing the Raku® Programming Language v6.d.
>> > Built on MoarVM version 2022.03-13-ga3476e286.
>> >
>> >
>> >
>> > Regards,
>> > David Santiago
>> >
Thread Previous
|
Thread Next