开发者

Multiprocessing between different languages such as PHP and Python

I asked a question before about how to do multiprocessing in Python (although I did not use the word multiprocessing in the former question, bec开发者_开发百科ause I was not sure I was asking about that yet).

Now I am wondering how to do multiprocessing when you have more then one language involved, particularly if you have a PHP script that calls a Python script. In that case how can you have both the PHP script and the Python script multiprocess, and communicate with each other (send variables back and forth) as they multiprocess?


One way to this would be though web services. You could have a PHP process sitting on a web server and running and calling a Python web service (using CherryPy) multiple times. You would pass variables using a standard object notation such as JSON which can be efficiently encoded/decoded by both PHP and Python.

You could also do the reverse of this with a Python service making multiple calls to a PHP service.

In both cases, since you're limited by a certain number of concurrent connections you don't need to worry about handling the threads yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜