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

Stefan Rank list-ener at strank.info
Wed May 2 08:13:34 EDT 2007


on 18.04.2007 20:37 Jörgen Stenarson said the following:
> Hi Stefan,
> 
> I have done some more experimenting. And now I think I have something 
> resembling what you were after. If you replace the emacs.py file in 
> pyreadline/modes/emacs.py with the attached version. Then running the 
> async_test.py should give you a prompt where you can type away and at 
> the same time the window title has a counter that is increased every 
> second. Make sure you have a recent update from svn before replacing 
> emacs.py.

Hi Jörgen,

attached is a small testfile using your modified emacs.py.
Works as expected.
I added some monkeypatching to expose a GNU-readline-callback-api-alike 
as module level functions.
If these look good to you, it would be great if you could incorporate 
them into pyreadline.

I am not sure about handling of Ctrl-C/D... but for users of the 
callback interface, a keyboard interrupt will typically occur outside of 
readline code, so it's the concern of the calling code (which is waiting 
for events) anyway.
I will also try to expose the GNU readline callback variant on Linux 
using ctypes and see how it behaves.
(Next step towards world domination: Get this and pyreadline into the 
Python standard library... ;-)

As for twisted: to use this callback interface I am subclassing 
twisted.internet.stdio.StandardIO (as ReadlineIO), and it sort of works 
already.
Currently, I am not really sure about when and where to add '\r\n' (or 
even '\n'? )... to the prompt? to printing of the result? ... but that 
is a minor problem.

cheers,
stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: readlinecallbacktest.py
Type: text/x-python
Size: 3388 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20070502/ce3882e4/attachment.py>


More information about the IPython-dev mailing list