且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Linux上运行的Python脚本如何在Wine下运行的Python脚本中调用例程?

更新时间:2023-10-21 13:27:04

您可以使用XMLRPC客户端和内置于Python的stdlib的服务器来执行所需的操作.只需使您的Wine-Python将所需的函数作为XMLRPC方法公开,并从任何其他Python程序对该进程进行进程间调用即可.

You can use the XMLRPC client and servers built-in Python's stdlib to do what you want. Just make your Wine-Python expose the desired functions as XMLRPC methods, and make an inter-process call from any other Python program to that.

它也适用于从CPython调用Jython或IronPython中运行的函数,也可以跨Python2和Python3调用-模块文档中包含的示例本身就足够了.只需检查一下文档即可:

It also works for calling functions running in Jython or IronPython from CPython, and also across Python2 and Python3 - the examples included in the module documentation themselves should be enough.Just check the docs: https://docs.python.org/2/library/xmlrpclib.html

如果您需要在客户端异步调用,或者在服务器站点上响应多个进程,则可以找到其他框架来构建调用-Celery还应该在保留多个不同Python的同时工作呼叫兼容性,并且在性能方面肯定足够.

If you need the calls to be asynchronous on the client side, or the server site to respond to more than one process, you can find other frameworks over which to build the calls - Celery should also work across several different Pythons while preserving call compatibility, and it is certainly enough performance-wise.