I would like to create a shell which will control a separate process that I created with the multiprocessing module. Possible? How?
EDIT:
I have already achieved a way to send commands to the secondary process: I created a code.InteractiveConsole
in that process, and attached it to an input queue and an output queue, so I can command the console from my main process. But I want it in a shell, probably a wx.py.shell.Shell
, so a user of the program could use it.
Note: The codeStr I stole from the first poster may not work here due to some pickling issues. But the point is you can execute your own codeStr remotely in a shell.
You can create a
Queue
which you pass to the separate process. From the Python Docs:EXAMPLE: In the wx.py.shell.Shell Docs the constructur parameters are given as
I have not tried it, but
locals
might be a dictionary of local variables, which you can pass to the shell. So, I would try the following:Inside the shell, you should then be able to put your commands into
cmd_queue
which have then to be read in the parent process to be executed.