This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tim.peters
Recipients Kevin Shweh, SnoopJeDi, bjs, eryksun, pitrou, serhiy.storchaka, tim.peters, vstinner
Date 2022-02-14.01:03:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644800585.91.0.902729501528.issue46726@roundup.psfhosted.org>
In-reply-to
Content
> It's nice that _maintain_shutdown_locks() gets
> called in _stop(), but the more important call site is in
> _set_tstate_lock().

I didn't have that in mind at all. What at the Python level cares whether the thread is alive? Well. is_alive() does, and it calls _wait_for_tstate_lock() __repr__() does, and it calls is_alive() (which I added years ago, else repr could keep claiming a thread was alive weeks ;-) after it actually ended). join() does, and it calls _wait_for_tstate_lock().

Anything else? Not off the top of my head. The point is that if _wait_for_tstate_lock() fails to call _stop() for some reason when it "should have" called it, it's not fatal. Anything that _cares_ will call it again. Indeed, it was all designed so that it could be called any number of times, redundantly or not, and without any explicit synchronization.

For the rest, I value clarity above all else here. This code has a long history of being the subject of bug reports. The cost of an "extra" call to .locked() is just trivial, especially given that calls to _wait_for_tstate_lock() are typically rare.
History
Date User Action Args
2022-02-14 01:03:05tim.peterssetrecipients: + tim.peters, pitrou, vstinner, serhiy.storchaka, eryksun, Kevin Shweh, bjs, SnoopJeDi
2022-02-14 01:03:05tim.peterssetmessageid: <1644800585.91.0.902729501528.issue46726@roundup.psfhosted.org>
2022-02-14 01:03:05tim.peterslinkissue46726 messages
2022-02-14 01:03:05tim.peterscreate