[IPython-dev] RE: [IPython-user] ANN: IPython 0.6.3 is out, with matplotlib support.

Tom Locke tom at livelogix.com
Wed Sep 1 01:00:43 CDT 2004

> I'd be
> especially interested in one that doesn't require constant polling,
> approach is just not acceptable in production code.  I can't simply
> all of the CPU because someone is running a prompt :)

Busy polling doesn't mean taking *all* of the CPU. It all depends just
how busy it is.

By inserting a time.sleep() into the polling loop, CPU usage could be
entirely negligible, while still maintaining responsiveness in the GUI

In fact, I don't think it's possible (in a single threaded environment)
to dispatch events from two distinct event queues without polling. 

To make this work on Linux (and other platforms), you need to do the
same trick with the 'real' readline.

readline defines a global variable rl_event_hook. A function pointer
that gets called at the right place in the readline input loop. Python
sets this to PyOS_InputHook(), which is in fact EventHook() from

EventHook loops around, dispatching events to Tk, whilst keeping an eye
on stdin. When stdin is ready, is just returns so that readline can do
its bit.

What is needed, is for Wx and/or Gtk to define their own EventHook and
attach it to rl_event_hook when the Wx/Gtk module is initialized.

Seems to me this is a Wx/GTK issue more than an IPython issue (I assume
these GUI libraries block the regular Python prompt too?).

I guess it could be done entirely in Python using ctypes??


More information about the IPython-dev mailing list