[IPython-dev] IPython inputhook, higher rate?

Thomas Kluyver takowl at gmail.com
Tue Sep 30 13:36:08 EDT 2014


Hi Martin,

Thanks for looking into this. We would be interested in having a better way
to integrate event loops with getting input in the terminal. It's probably
not practical to push that straight into core Python, and even if it was,
it would be some time before we could scrap our inputhook functionality in
favour of a new feature in Python 3.5.

You might want to look instead at basing it on a project like pyrepl, which
implements readline-like features in Python. Its features list specifically
mentions: "no hogging of control -- it should be easy to integrate pyrepl
into YOUR application's event loop."

Best wishes,
Thomas

On 30 September 2014 08:05, Martin Teichmann <lkb.teichmann at gmail.com>
wrote:

> Hi,
>
> I just saw this thread about why and how the python
> inputhook works, and how to integrate other event loops
> with IPython, using said input hooks.
>
> The actual problem is that the python input routine blocks
> while it reads from the console. This is completely
> unnecessary, as the underlying GNU readline library does
> not require a block at all. Down in the python interpreter,
> something like the following happens (it's in C in original).
>
> while True:
>     PyOS_InputHook()
>     select(stdin, timeout=100)
>     if something_in_stdin:
>         call_GNU_readline_to_read_one_char()
>
> so, python defines its own event loop! As one can see
> very clearly, from the IPython standpoint this is completely
> stupid: we want our own event loop to run (eg, the Qt
> event loop), and once something arrives at stdin, call
> GNU readline to process whatever arrived.
>
> I already wrote the necessary changes and already put
> up some patch on the python issue tracker:
> http://bugs.python.org/issue22412
>
> Greetings
>
> Martin
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140930/2030dcac/attachment.html>


More information about the IPython-dev mailing list