2017-03-16 68 views
4

假设我有一个简单的python脚本,它使用subprocess模块执行elixir/erlang脚本。Elixir/Erlang:与外部进程通信

假设python脚本的操作系统PID为P1,而运行的衍生elixir/erlang脚本的操作系统PID为P2

我想知道P1P2之间的通信是否可能。更具体地讲,P1写东西的P2stdin,并P2读取P1接收到的输入,并写入了相应的输出,以自己的stdoutP1P2stdout读取和再次写东西的P2stdin等。

我知道另一种方式是可能的,即从elixir/erlang中产生外部进程,然后与进程进行通信。任何帮助表示感谢,谢谢。

+2

当然,为什么不呢?只需从Elixir使用'IO.gets'(或类似的)读取并使用'IO.puts'(或类似的)写入,然后在Python中做相反的操作(http://stackoverflow.com/questions/8475290/how-do-i -write至A-蟒蛇 - 子 - 标准输入)?你试过这个吗? – Dogbert

+0

谢谢!如果'P1'也是一个灵丹妙药的过程呢? – stark

+1

您可以使用端口而不是子进程。 https://hexdocs.pm/elixir/Port.html – Dogbert

回答

0

像Dogbert说的,你可以使用Ports来代替。退房Erlporthere是Elixir和Python之间沟通的博客文章