[Python-Dev] bug 754449 and threads raising exceptions at
"Martin v. Löwis"
martin at v.loewis.de
Tue Feb 10 13:54:00 EST 2004
> So you are classifying this as a bug then. That was part of my question
> since it only happens if you don't handle your threads properly (or at
> least I think properly; I would assume it is common practice to close
> down your threads).
Certainly: in a properly working program, one would terminate all
threads first before trying to exit the program. Failure to do so
should cause an exception (or otherwise have an "obvious" meaning).
However, that exception should not be a "double-fault"; instead,
it should give a clear indication what the problem is.
> For some crazy reason having to delve into the world of thread libraries
> for those cases where there is not an equivalent pthread_cancel does not
> sound fun. =)
You could safely assume that there is an equivalent to pthread_cancel;
not having thread cancellation on non-pthreads-non-win32 systems seems
acceptable to me (especially since we don't have thread cancellation on
any system at the moment).
Unfortunately, pthread_cancel is insufficient for Python, as you also
want stack-unwinding on the cancelled thread, so that it can decref
all objects it holds.
If you can make this work, we could specify that exiting the interpreter
when some threads are still sleeping inside Python code causes those
threads to be cancelled.
More information about the Python-Dev