j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
On Jun 27, 2019, at 13:36, Michael Foord firstname.lastname@example.org wrote:
On Thu, 27 Jun 2019 at 20:53, Yonatan Zunger email@example.com 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.