[IPython-dev] ipython embedded in twisted, no threads

Stefan Rank list-ener@strank.i...
Mon Apr 16 01:31:27 CDT 2007


Hi,
[apologies if this arrives twice, posting via gmane didn't work - yet.]

attached is an ugly first attempt at embedding IPython in a twisted
application without using threads.

twisted.internet.stdio and a LineReceiver implementation are responsible
for getting input events.
I had to subclass the IPython shell and rearrange code to
create a non-blocking callback interface (splitting on the main,
blocking, raw_input call).

It's far from perfect: readline functionality is missing (no commandline
navigation, history navigation, completion), and sometimes continuation
lines eat the input counter (In[2] ... In[4]).

Would IPython developers be interested in patches that allow a less ugly
version of such a callback-friendly subclass? ;-)
The basic idea: refactor the main loop (InteractiveShell.interact) to::

    setup()
    while ...:
        promptforline()
        raw_input
        handleline()
    teardown()

(I think it might also be interesting for the frontend to the IPython
parallel computing effort, which uses twisted.)

cheers,
stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: twistedipython.py
Type: text/x-python
Size: 13037 bytes
Desc: not available
Url : http://lists.ipython.scipy.org/pipermail/ipython-dev/attachments/20070416/abe920f2/attachment.py 


More information about the IPython-dev mailing list