bpo-39812: Remove daemon threads in concurrent.futures#19149
Conversation
|
I considered adding a unit test for That being said, I think it would be worthwhile to add a test along those lines if it were to be added to the public API for |
Sorry, something went wrong.
|
(Note that |
Sorry, something went wrong.
|
I'm 99.99% certain the |
Sorry, something went wrong.
|
I opened a separate issue to address the (unrelated) buildbot refleaks from |
Sorry, something went wrong.
pitrou
left a comment
There was a problem hiding this comment.
Thanks for doing this. I think _register_atexit deserves at least some basic unit test(s). It should be fairly easy by spawning e.g. a subprocess and checking its output.
Sorry, something went wrong.
No problem, thanks for the review. :-)
Yeah, after having some additional time to think about it, I think we'd be better off with a couple of basic unit tests for it, even if it's internal. I'll work on those next. |
Sorry, something went wrong.
|
Going to restart the CI (via close and re-open) since it failed in the "Install Dependencies" stage. |
Sorry, something went wrong.
|
@pitrou I believe that I've addressed the review comments. Let me know if the unit tests I added are sufficient. |
Sorry, something went wrong.
|
(closing and reopening to trigger CI) |
Sorry, something went wrong.
That's a good idea. |
Sorry, something went wrong.
|
Oh, and yes, the unit tests look sufficient for an internal function :-) |
Sorry, something went wrong.
By the way, with GitHub actions for some reason, it leaves the previous CI failures and duplicates the tests when you close and re-open the PR. So some of the failures showing are from the first time (before I closed and re-opened it), that's why there's 3 of each GitHub actions test. I'm not certain why they're failing in the early stages though. If it happens again, I'll start a thread on python-dev.
Great! I'll work on the "What's New" entry next; it shouldn't take long. :-) (It should also clear the old CI tests since it's a different commit) |
Sorry, something went wrong.
|
@gvanrossum this PR needs to be reverted, but I no longer have my commit bit |
Sorry, something went wrong.
Please open a new issue with reasoning. In general we do not want daemon threads anywhere anymore. Their existence has turned out to be a misfeature as they mean you cannot safely finalize a Python runtime when such threads are present. |
Sorry, something went wrong.
|
I am also curious why @aeros stated that this needs reverting. It looks like a backwards incompatible change (which is why I ended up reading this ticket), but it looks like affected projects can easily cope. Did run into this because I manipulate interpreter shutdown for a test suite, which at times got stuck due to some non-daemon thread "helpfully" started in some library package. That code is not used in production but for diagnostics, as the failure was intermittent and difficult to reproduce.
I think nobody "wants" units of execution that are just killed without notice in whatever state they are. I'd just like to advise against dropping them without a replacement. The use case I see is dealing with threads getting stuck in some native code. This came up in my career a few times and was always a giant PITA to solve (or, actually, work around). What I'd like is a way to detach a thread in a way that it may not come back from extension code and just silently stops. I am not sure if and how that could be implemented, though. Sorry for the noise, got longer than anticipated. |
Sorry, something went wrong.
The leading theory is that he lost control over his account. That account's permissions have been dropped. |
Sorry, something went wrong.
Removes daemon threads from the Executor internals in concurrent.futures to allow for compatibility with subinterpreters (since they no longer support daemon threads with https://bugs.python.org/issue37266).
/cc @pitrou
https://bugs.python.org/issue39812