sending thread exceptions (was Re: RELEASED Python 2.3.1)

Alex Martelli aleax at aleax.it
Fri Sep 26 08:53:22 EDT 2003


Peter Hansen wrote:

> Anthony Baxter wrote:
>> 
>> On behalf of the Python development team and the Python community, I'm
>> happy to announce the release of Python 2.3.1 (final).
> 
> The highlights mention the existence of a new API
> PyThreadState_SetAsyncEnc, which is "deliberately accessible only from C",
> that can interrupt a thread by sending it an exception.
> 
> I can't find an online discussion of this, so I'm asking here.  Why was
> this
> made accessible only from C?  Is it dangerous?  Experimental?  Someone
> feels it will be used inappropriately if too readily available at the
> Python level?

As covered in previous discussion, basically the latest reason.


> Presumably somebody will come up with a little extension module or other
> technique for calling this which will let anyone use it at will, so I'm
> unclear on why it should be made inaccessible from Python.

Having to use a third-party extension module, or other kludge, will make
people more aware than this functionality is most likely NOT intended nor
appropriate for the use they have in mind (that's going to be the case
well over 90% of the time, IMNSHO based on teaching, consulting and
debugging lots and LOTS of horrid, inappropriate threading architectures
over the years).  I just wish that most of the threading-synchronization
constructs currently available in Python, and module thread first and
foremost, were just as "arm's length away", leaving module threading and
module Queue as "the only obvious way to do it" for 90%+ of people's
actual threading needs... a sufficiently selfish and short-sighted
consultant might think that would reduce their volume of business, but
IMHO -- by removing most of the threading-related issues of most Python
programs -- it would just make everybody's life a little bit better;-).


Alex





More information about the Python-list mailing list