Changing the script to not exploit the bug doesn't make the bug go away.   I 
don't see anywhere that rakudo doesn't support this, I know there is a bug on 
moarvm where they're discussing handle passing between threads being the issue

Sent from Outlook




On Sun, Oct 11, 2015 at 4:23 AM -0700, "Stefan Seifert via RT" 
<[email protected]> wrote:
I think, this is just a bug in the test script and not in Rakudo's Channels.
The "while my $d = $conn.recv" loop will keep running until the connection is 
closed because recv will block and wait for more input. However, you never 
close the connection in your client.
With an added $conn.close and some minor adjustments for changes in Rakudo 
since this bug was opened (comments inline), the following script runs and 
gives the intended output:

#!/usr/bin/env perl6

use Test;

my $supply = Supply.new;

my $promise = start { # start is no function, don't call it like one
  # Rakudo prohibits calling .accept in a different thread to the one opening 
the connection
  my $server = IO::Socket::INET.new(:localhost<127.0.0.1>, :localport(8091), 
:listen);
  my $conn = $server.accept;
  $supply.emit($conn);
};

$supply.tap(-> $conn {
  my $data = '';
  'Starting to receive.'.say;
  while my $d = $conn.recv {
    $data ~= $d;
  }
  'Never gets to this line.'.say;
  ok $data eq 'Hello, perl6.';
});

sleep 1; # give the server time to connect
my $conn = IO::Socket::INET.new(:host<127.0.0.1>, :port(8091));
'Connection sending data.'.say;
$conn.print("Hello, perl6.");
$conn.close;

await $promise;

Reply via email to