How would a Python script running on Linux call a routine in a Python script running under Wine?

前端 未结 2 478
一个人的身影
一个人的身影 2020-12-21 11:38

I have a Python (3) script running on Linux, referred to as the main script, which has to call a routine from a proprietary DLL. So far, I have solved this with Wine using t

相关标签:
2条回答
  • 2020-12-21 11:57

    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.

    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

    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.

    0 讨论(0)
  • 2020-12-21 12:17

    You want to communicate between two processes, where one of them is obscured by being under the control of the WINE engine.

    My first thought here is to use a very decoupled form of IPC. There are just too many things that can go wrong with tight coupling and something like WINE involved.

    And finally, how can this be made easy for someone new to this kind of stuff?

    The obvious answer is to set up a web server. There are plenty of tutorials using plenty of packages in Python to respond to HTTP requests, and to generate HTTP requests.

    So, set up a little HTTP responder in your WINE process, listen to some non-standard port (not 8080 or 80), and translate requests into calls to your DLL. If you're clever, you'll interpret web requests (http://localhost:108000/functionname?arg1=foo&arg2=bar) into possibly different DLL calls.

    On the other side, create a HTTP client in your non-WINE code and make requests to your server.

    0 讨论(0)
提交回复
热议问题