j: Next unread message
k: Previous unread message
j a: Jump to all threads
j l: Jump to MailingList overview
On Thu, 20 Jun 2019 at 16:33, Guido van Rossum firstname.lastname@example.org wrote:
On Thu, Jun 20, 2019 at 8:21 AM Michael Foord email@example.com wrote:
It works by raising an exception in the target thread, which the thread is free to handle (usually for cleanup and then reraise).
Sure, those are the right semantics. How does it stop blocking I/O though? Suppose the thread is waiting for a server to return a response which just isn't ever going to come, but the connection somehow is kept open by the other side?
Sorry, resending to list as well.
It used to be on the CLR getting back control. So it couldn't handle that case. (.NET 1.1).
It has since been improved. It still blocks on the execution of unmanaged code (or computation in a finally block handling the ThreadAbortException), but blocking IO can be interrupted:
If Abort is called on a thread that is blocked or is sleeping, the thread is interrupted and then aborted.
This SO question on the topic says:
There are 2 things I see you could do. 1 is that if you have started this TcpListener thread from another you can simply call Thread.Abort instance method on the thread which will cause a threadabortexception to be thrown within the blocking call and walk up the stack.
-- --Guido van Rossum (python.org/~guido) Pronouns: he/him/his (why is my pronoun here?)
Python Consultant, Contractor and Trainer