简体   繁体   English

如何与 Python 中已经运行的 Linux 进程通信?

[英]How can I communicate with an already running Linux process in Python?

I am simulating an https session between a client and server within the same Ubuntu Linux virtual machine.我在同一Ubuntu ZEDC383F0A5A3D474E虚拟机内的客户端和服务器之间模拟https session Naturally, the client process ( client.py ) sends requests to the server process ( server.py ) which will already be running before the client spawns to make its request.自然地,客户端进程 ( client.py ) 向服务器进程 ( server.py ) 发送请求,服务器进程在客户端生成请求之前已经在运行。 For security reasons, I would prefer avoid spawning an intermediate shell to pass commands to the server via something like the system() function call [ os.system module ];出于安全原因,我宁愿避免产生中间 shell 以通过诸如system() function 调用 [ os.system模块]之类的方式将命令传递给服务器; The server is an independent process that is already running so it does not make sense to use the subproccess module in Python because the server will not be a child process.服务器是一个已经在运行的独立进程,因此使用 Python 中的子进程模块没有意义,因为服务器不会是子进程。 Do I have to use sockets?我必须使用 sockets 吗? If so, what python module supports sockets?如果是这样,什么 python 模块支持 sockets? Is there some other form of interprocess communication on Linux? Linux 上是否还有其他形式的进程间通信? What to do?该怎么办? Thanks谢谢

You might have a look at ZeroMQ .你可以看看ZeroMQ It is simple to use and it provides a single abstraction to various communication modes, including sockets.它使用简单,为各种通信模式提供单一抽象,包括 sockets。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM