C-extension not threadable?

Dave Cole djc at object-craft.com.au
Wed Apr 17 20:57:08 EDT 2002


>>>>> "Martin" == Martin v Loewis <martin at v.loewis.de> writes:

Martin> Dave Cole <djc at object-craft.com.au> writes:
>> If you create a new thread state for the callback, what will happen
>> to Python exceptions raised in the callback?

Martin> They propagate back to the bottom of the callback. If you
Martin> don't treat them special, deleting the thread state will also
Martin> release the exception object and traceback object. Assuming
Martin> the thread callback came "out of nowhere", there is nothing
Martin> reasonable to do, anyway: you might want to print the
Martin> exception to stderr or something like that.

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.

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.

- Dave

-- 
http://www.object-craft.com.au



More information about the Python-list mailing list