Created
October 29, 2018 05:19
-
-
Save ryn1x/c313e63bd927a7e0309e2c6fe4a154e6 to your computer and use it in GitHub Desktop.
IPC using react/whenever
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
while 1: | |
x = input('') | |
if x == 'exit': | |
print('exiting...') | |
break | |
print(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pid: 22812 | |
inside | |
outside | |
exiting... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; |
[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
[23:22] ryn1x: instead of
whenever $proc.Supply.lines
I think you can do justwhenever $proc
[23:22] ah
[23:22] actually
[23:22]
whenever $proc.lines
?[23:22] ↑ that's the one, I think