basics to create a MML console in Python
I am looking to have a MML (man machine language) console written in Python as the only entry point to control and monitor a back-end process. Basically will be able to:
- attach to an existing back-end process
- if back-end process i开发者_开发知识库s not running, still open console and be able to spawn back-end process (by introducing the correct command)
- auto-complete permitted commands
- be able to change back-end process behavior based on the introduced commands
What would be the best way to achieve this? How to communicate the back-end process with a console that can be opened and closed without killing the back-end process, by this I mean that the console would not be the parent of that process.
Needs to be written in Python and will run on a CentOS, maybe some OS tools can help to communicate processes?
High on my list would be twisted. It's fairly easy to build a an interactive console with and it's Perspective Broker system would probably work well for you. Plus it's very robust, has a fast event loop, and it's very robust.
You could also use the cmd module, which was recently featured on Doug Hellmann's excellent site Python Module of the Week (PyMOTW).
For interprocess communication, ZeroMQ is fairly easy to work with, and it's very fast.
Maybe this is a start: http://code.google.com/p/squires/wiki/SquiresHowto
You could use a Socket to do the communication between Front- and Backend.
精彩评论