What RPC module should I use to implement RCP in Python and be able to change connection method later?

◇◆丶佛笑我妖孽 提交于 2019-12-31 05:30:50

问题


I do have to implement some RPC from Python to Python but the connection methods are quite limited for security reasons.

Currently it seems that I may be able to connect using SSH and run a single python script on the remote system.

This can change in the future when we may have to connect using something else, maybe telnet so I would like a solution that can work using different protocols.

Another potential limitation is regarding Python version, it has to work with Python 2.5-2.7 even if the client and the server are running different versions.

What I should use, please suggest only if you had successful experience with it, otherwise I can google too ;)


回答1:


I'd say that the easiest way to communicate two different python processes in your case is using pyro3. I've recently used pyro4 in a small project and it was very effective to let me focus in the information I wanted to send/receive rather than in the way to encode/decode it properly.

I recommend you to use v3 because v4 isn't tested against python 2.5 according to the tox.ini file in the sources, so you might have some problems there.

Regarding networking, this library takes care of the sockets itself, so there isn't any explicit support for telnet or ssh (although using paramiko is in the TODO list). Hene, you'll probably need to rely on ssh tunnels as in this example.




回答2:


As a partial solution for python 2.6+ you could have a look at Versile Python (currently in development), we just added support for reactor-driven byte communication over pipes (requires a platform which allows select.select on pipe file descriptors, i.e. not Windows). This enables links to VPy ORBs over pipes or stdin/stdout. See this recipe for an example how it can be used with ssh.

Versile Python requires python 2.6+ or 3.x so unfortunately does not work with 2.5.




回答3:


Spyne supports pluggable protocols and transports, but it doesn't support SSH (or any other socket-like transport) yet. It's a stable but quite new project -- especially the client logic needs some serious work.

As for your original question, among the serializers I'm familiar with, (which is mostly what you see on the spyne web site) the most suitable to pipe through a stream transport is MessagePack as it supports the iterator-over-file-like-object (a.k.a the streaming deserialization) interface.




回答4:


Would it interest you to use something with rabbitmq for sending receiving commands and logs?

https://github.com/nvalerkos/cronio

It's python 2.7 needs a rabbitmq



来源:https://stackoverflow.com/questions/8430243/what-rpc-module-should-i-use-to-implement-rcp-in-python-and-be-able-to-change-co

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