Ausum Studio wrote at 2005-8-19 01:31 -0500:
How do you stop a long process just triggered, i.e., by accident?
If the process is an external process (rather than a thread), you sent it a signal (e.g. a SIGTERM). This may not work in Python 2.3.x for most signal, as these Python versions block signals in the non main thread and this is passed down to processes created by these threads. A process can however reactivate some (or all) signals. Furthermore, the process can still be killed with signal SIGKILL. The bug is fixed in Python 2.4. If the process is rather a thread, it is very difficult to stop it. If the thread is inside a C extension, you cannot abort it without the risk to lose resources or get into inconsistencies (there is no "try: ... finally: ..." in "C"). Python has a C level API function that allows you to deliver an exception to a thread. Once the thread reaches Python again, it will see the exception and process it in the normal way. This might help you in some maybe most cases -- but probably not always... -- Dieter