IPC (inter process communication) between python and java

廉价感情. 提交于 2019-11-30 08:29:46
Jeremy Brown

This is the opensource solution Google uses to do IPC between Java and Python. https://code.google.com/p/protobuf/

Recommended.

Adam Fraser

I attempted to code a solution using pipes but it seems that they just aren't well suited to sending multiple messages back and forth with potentially large data attached. Rather, they seem ideal for opening a "worker" style program that runs, responds, and dies.

Looking into socket programming, I found a fantastic resource here: https://web.archive.org/web/20080913064702/http://www.prasannatech.net/2008/07/socket-programming-tutorial.html

The tutorial presents TCP and UDP variants of a simple chat program written in 4 languages. I ended up using and modifying the TCP Java client and Python server.

Vebjorn Ljosa

Use subprocess.Popen to start the Java process and establish pipes to communicate with it. For serializing and deserializing data efficiently in a language-neutral, platform-neutral, extensible way, take a look at Protocol Buffers (contributed to by Jon Skeet!).

I had a similar situation where I had to communicate between a Java process and a Linux process. I used named pipes.

Try mkfifo() implementation in python.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!