[Python-ideas] Thread stopping

Andrew Svetlov andrew.svetlov at gmail.com
Mon Apr 2 17:15:08 CEST 2012


On Mon, Apr 2, 2012 at 5:54 PM, Guido van Rossum <guido at python.org> wrote:
> Perhaps off-topic, but the one thing that isn't easy to do is stopping
> a thread that's blocked (perhaps forever) in some blocking operation
> -- e.g. acquiring a lock that's been forgotten or a read on a
> malfunctioning socket (it happens!). Having to code those operations
> consistently with timeouts is a pain, so if there was a way to make
> those system calls return an error I'd really like that.
>
> I'm not super worried about skipping finally-clauses, we can figure
> out a hack for that.
>

Python already has support for processing EITNR in threading
synchronization objects. It's done to switch GIL to main thread if
signal received when GIL acquired by some background thread. That
mechanic can be easy extended for thread interruption case I think.

Windows is also not a problem.



More information about the Python-ideas mailing list