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

Ravi lists_ravi@lavabit....
Sat Sep 17 12:38:06 CDT 2011


Hi,
  Is it possible to start up an ipython 0.11 kernel as a separate process that 
acts as a plot server for other (possiby remote) processes? In more detail, 
here's the general idea:

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.

For example, the extension module has roughly the following C code:

   double *x, double *y;
   wait_for_data();
   long len = marshall_data( x, y ); // Fill up x and y
   g = PyGILState_Ensure();
   Py_BEGIN_ALLOW_THREADS
   put_xy_into_numpy_arrays( x, y, len ); // as x and y in namespace "special"
   PyObject *p = PyRun_String( "figure(); plot( special.x, special.y )" );
   Py_XDECREF( p );
   Py_END_ALLOW_THREADS
   PyGILState_Release();

Questions:

1. How do I ensure that the kernel does not exit until it receives a signal?

2. Will all the GUI toolkit initialization be handled by ipython?

Regards,
Ravi



More information about the IPython-User mailing list