I'm trying to hook up my Vim so I can send commands to a running IPython instance. There are scripts for this, but they are outdated. I'm trying to write a new one.
My main stumbling block right now is the proper way to make IPython listen to incoming network connections in the background (i.e. a different thread, other solutions are welcome) and executing the received commands in the main thread. Earlier scripts did not execute commands in the main thread and would crash for instance matplotlib regularly.
I see that twisted provides a ThreadedSelectReactor, but I'm at a loss as to how to use it properly with IPython.
Update
A scenario example would be:
2 Windows open, one is a terminal running IPython, one is Vim where you are editing a python script. You select a line in Vim and hit C-Enter, Vim sends the line to the IPython instance, which executes it and prints the result in the IPython terminal, just as if you had copy/pasted the line over myself.
(Matlab users know how useful this functionality can be.)