C-extension not threadable?

Martin v. Loewis martin at v.loewis.de
Thu Apr 18 02:41:41 EDT 2002


Dave Cole <djc at object-craft.com.au> writes:

> I think that it is preferable to keep the exception and propagate it
> back from the callback through the API to the thread which called the
> API.  I am not sure why discarding the exception would be a good idea.

That assumes that the call originated from Python. If some library has
created the thread (e.g. in response to an incoming network connection
which was accepted by the library), there won't be anybody to
propagate the exception to.

> IMO, from the point of view of the extension module user it should not
> be visible that there was some non-Python code between the Python code
> where the exception was raised and the Python code which called the
> module API.

Again, assuming there is Python code on both sides, and also assuming
it is possible to pass something through from one end to the
other. *If* that is possible, you can just as well pass the thread
state through. If you cannot pass the thread-state through, due to the
design of the library you are wrapping, tough luck: chances are low
that you can pass the exception back.

Regards,
Martin



More information about the Python-list mailing list