[IPython-User] modify a running script

Piotr Zolnierczuk piotr.zolnierczuk@gmail....
Fri Sep 23 12:16:09 CDT 2011


>
>
> On Thu, Sep 22, 2011 at 10:38 AM, Piotr Zolnierczuk
> <piotr.zolnierczuk@gmail.com> wrote:
> > Hi,
> > I came across this an interesting new use case.
> >
> > A user wants to run a (long running experiment control) script and pause
> it
> > at some point, modify something (e.g. a variable) and continue the
> > execution.
> > My answer was to use pdb from within ipython. Is there (out there)
> anything
> > else that could be used for this?
>
> You can try and except KeyboardInterrupt, or register a signal handler
> for it as demoed here:
>
> import signal
> import sys
> def signal_handler(signal, frame):
>    print 'you can embed some logic here when user pressed Ctrl+C!'
>    sys.exit(0)
> signal.signal(signal.SIGINT, signal_handler)
> print 'Press Ctrl+C'
> while True:
>    continue
>
> best,
> --
> Paul Ivanov
> 314 address only used for lists,  off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7
>
>
> That's an interesting piece of code. I did not know that Python supports
signals (just like in the old Unix days and C). And it even works on an old
XP box. I am going to use this for something for sure!

That does not solve the 'modify and continue' problem, does it?

But will keep playing.

Thanks

Piotr


-- 

Piotr Adam Zolnierczuk
e-mail: piotr@zolnierczuk.net
www:   http://www.zolnierczuk.net
_____________________________________
written on recycled electrons
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20110923/0529ed51/attachment.html 


More information about the IPython-User mailing list