[IPython-User] ipython --pylab as a plot server

Fernando Perez fperez.net@gmail....
Mon Sep 19 14:08:41 CDT 2011


On Sat, Sep 17, 2011 at 10:38 AM, Ravi <lists_ravi@lavabit.com> wrote:
> 1. Start up ipython 0.11 kernel with --pylab
> 2. Run an initial script that loads an extension module, say EXT
> 3. EXT spawns a separate C thread that listens for incoming data
>   - when data comes in, it is converted to numpy arrays
>   - the numpy arrays are put in special variables in a special namespace
>   - then a plot string is evaluated
> 4. The main thread loops until killed by SIGTERM or equivalent.

Yup, I can't think of any problem, though it won't work (as easily)
with 0.11, since the startup command

ipython kernel

was only added in the 0.12 serie.  Though if this is a major
limitation, it can be worked around in 0.11, but it would be cleaner
if you can do this with 0.12.

If you start the kernel with

ipython kernel --pylab

it will do all your GUI handling for matplotlib.  You can connect to
it with a qtconsole to control it interactively if you want.

As far as preloading your extension, the simplest would be to define a
profile for your application with

ipython profile create <yourappname>

and edit the profile config file to execute at startup your own
script.  You can then in your startup script load any additional code
you want.

You can cleanly shut down that kernel from a Qt console as well, or by
installig a signal handler (we should probably make this a little
easier).

So there may be one or two rough edges, but by and large what you want
should mostly 'just work'.  Let us know if it proves to be otherwise.

Cheers,

f


More information about the IPython-User mailing list