On Jun 27, 2019, at 13:36, Michael Foord <[email protected]> wrote:
> 
>> On Thu, 27 Jun 2019 at 20:53, Yonatan Zunger <[email protected]> wrote:
>> Generally, threads don't have a notion of non-cooperative thread 
>> termination. 

> That's precisely why thread cancellation in managed languages (like Python 
> is) raise an exception to terminate the the thread and honour finally blocks. 

And that’s precisely why your proposal to use TerminateThread on Windows can’t 
work. And why .NET Thread.Abort, etc., don’t use TerminateThread—and, in fact, 
don’t break out of most blocking calls.

>> The POSIX threading model does include the ability to send a signal to a 
>> particular thread using pthread_kill(). 
> 
> This is not what is being suggested. Read about the semantics of thread 
> killing in C# and Java. 

While Yonatan is talking about the old pthread_kill function rather than the 
modern one you suggested, there are still similar issues. It still works by 
sending a signal under the covers, it just provides a much nicer API (but one 
that nobody uses—and in particular, Python doesn’t) to handle that signal 
indirectly, by managing thread cancellation state and type and cleanup 
functions.

_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/5EOINH2ANL6EFYX35XRUMNUIE4F44LER/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to