[IPython-dev] Reaping idle ipython server instances

Stephen Chan sychan at lbl.gov
Thu Dec 19 19:35:43 EST 2013


Hi,
    I've been working with docker and specifically Jiffylab for
sandboxed, dynamically provisioned IPython notebook instances and
wondered if there was any suggestions about how to reap idle IPython
server instances.
    Ideally the ipython server would simply notice that there has been
no activity, and no active client sessions after some period of time
and then politely exit. But that may be wishful thinking.
    Any suggestions for how to go about it?

    The generic docker approach seems to be to monitor network
activity periodically and if there isn't any, shutdown the container
using the docker API. I can do this, though I am worried about long
running tasks that may result in the network traffic being idle while
its running.
    An 'external' option that might work seems be to examine the
output from 'netstat' to see if there are established TCP connections
to the listening port on the notebook instance. If a certain amount of
time has passed without seeing an established connection, shutdown the
container. It would be pretty straightforward to implement, but I am
wondering if there is something else that others have used.

   This would be for the current 1.x branch of IPython.

   Thanks!
   Steve



More information about the IPython-dev mailing list