[Python/C API] How to break a script execution ?
Misiek
herrmisiek at precz.ze.spamem.wp.pl
Thu Jan 16 12:56:35 EST 2003
Hello everybody,
I have written a MFC application that allows to run Python's scripts with
using Python/C API. All works perfectly, but I don't know how to break a
script execution on demand (something like pressing Ctrl+C in Python).
Suppose I have a script that simply execute an endless loop and I would like
to stop it execution by clicking a button in my application and then dump to
my application an iteration count. Here is an example script:
def main():
try:
i = 0
while 1:
i = i + 1
except KeyboardInterrupt:
print "Iteration: ", i
main()
Is there any possibility to break a script execution from my application and
catch the exception? How to do it? I would be grateful for any
suggestions...
Regards,
Misiek
More information about the Python-list
mailing list