[IPython-User] modify a running script

Paul Ivanov pivanov314@gmail....
Thu Sep 22 17:07:18 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


More information about the IPython-User mailing list