Skip to content

Instantly share code, notes, and snippets.

@ryn1x
Created October 29, 2018 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryn1x/c313e63bd927a7e0309e2c6fe4a154e6 to your computer and use it in GitHub Desktop.
Save ryn1x/c313e63bd927a7e0309e2c6fe4a154e6 to your computer and use it in GitHub Desktop.
IPC using react/whenever
#!/usr/bin/env python3
while 1:
x = input('')
if x == 'exit':
print('exiting...')
break
print(x)
pid: 22812
inside
outside
exiting...
#!/usr/bin/env perl6
use v6;
my $isready = False;
my $proc = Proc::Async.new: 'python3', 'child-proc.py', :w;
start react {
whenever $proc.Supply.lines { put $_ }
whenever $proc.ready { say "pid: $_"; $isready = True; }
whenever $proc.start {}
$proc.put: 'inside';
}
until $isready {};
$proc.put: 'outside';
$proc.put: 'exit';
sleep 1;
@ryn1x
Copy link
Author

ryn1x commented Oct 29, 2018

[23:22] ryn1x: instead of whenever $proc.Supply.lines I think you can do just whenever $proc
[23:22] ah
[23:22] actually
[23:22] whenever $proc.lines ?
[23:22] ↑ that's the one, I think

@ryn1x
Copy link
Author

ryn1x commented Oct 29, 2018

[23:23] ryn1x: instead of until $isready {};
[23:23] use await $proc.ready

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment