C-extension not threadable?
Dave Cole
djc at object-craft.com.au
Thu Apr 18 04:46:24 EDT 2002
>>>>> "Martin" == Martin v Loewis <martin at v.loewis.de> writes:
Martin> 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.
Martin> That assumes that the call originated from Python. If some
Martin> library has created the thread (e.g. in response to an
Martin> incoming network connection which was accepted by the
Martin> library), there won't be anybody to propagate the exception
Martin> to.
The assumption is not an assumption in this case because the original
question was about this very situation.
Marcus> The thread is started like this:
Marcus>
Marcus> T=threading.Thread(group=None,target=ExtModule.CFunction,name=None,
Marcus> args=(a,b,c,self.callback))
Marcus> T.start()
>> 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.
Martin> Again, assuming there is Python code on both sides, and also
Martin> assuming it is possible to pass something through from one end
Martin> to the other. *If* that is possible, you can just as well pass
Martin> the thread state through. If you cannot pass the thread-state
Martin> through, due to the design of the library you are wrapping,
Martin> tough luck: chances are low that you can pass the exception
Martin> back.
Agreed, but (I thought) we were talking about the situation where
Python created the threads.
- Dave
--
http://www.object-craft.com.au
More information about the Python-list
mailing list