GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() by gvanrossum · Pull Request #110884 · python/cpython

Conversation

@gvanrossum

@gvanrossum gvanrossum commented Oct 14, 2023 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Based on #110790, which was closed.

  • Issue: test_asyncio.test_subprocess leaked dangling threads on PPC64LE Fedora Stable 3.x: #110205

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vstinner and others added 4 commits October 13, 2023 02:30
@vstinner
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads()
d414ed2
ThreadedChildWatcher._join_threads() now clears references to
completed threads.

test_asyncio.utils.TestCase now calls _join_threads() of the watcher,
uses SHORT_TIMEOUT to join a thread, and then raises an exception if
there are still running threads.

Rename also ThreadedChildWatcher threads to add "asyncio-" prefix to
the name.
@vstinner
Don't create a new list
f161daa
@vstinner
Fix typo: self.threads => self._threads
dbbad2d
@gvanrossum
Fix code to clear references to terminated threads
85b79b2
@bedevere-app bedevere-app Bot mentioned this pull request Oct 14, 2023
test_asyncio.test_subprocess leaked dangling threads on PPC64LE Fedora Stable 3.x: #110205
Closed
gvanrossum added 2 commits October 14, 2023 23:38
@gvanrossum
Merge remote-tracking branch 'upstream/main' into asyncio_clear_watch…
0d802c2
…er_threads
@gvanrossum
Make close_loop an instance method so it can call self.fail()
a8ffeee
@gvanrossum gvanrossum added tests Tests in the Lib/test dir topic-asyncio skip news needs backport to 3.11 only security fixes needs backport to 3.12 only security fixes labels Oct 14, 2023
gvanrossum added 2 commits October 15, 2023 00:15
@gvanrossum
Filter out dead or daemon threads
bda45c8
@gvanrossum
Back to basics
566fb52
@gvanrossum
gvanrossum force-pushed the asyncio_clear_watcher_threads branch from fd13f23 to 566fb52 Compare October 15, 2023 00:25
gvanrossum added 2 commits October 15, 2023 09:43
@gvanrossum
Delete stray code
f8090c1
@gvanrossum
Add a comment
aed1a89
@gvanrossum
gvanrossum marked this pull request as ready for review October 15, 2023 09:25
@gvanrossum
gvanrossum requested review from 1st1, asvetlov, kumaraditya303 and willingc as code owners October 15, 2023 09:25
@bedevere-app bedevere-app Bot added the awaiting core review label Oct 15, 2023
@gvanrossum

gvanrossum commented Oct 15, 2023

Copy link
Copy Markdown
Member Author

Reviewers, please have a look at this comment in the issue for background on what I ended up doing:
#110205 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum

gvanrossum commented Oct 15, 2023

Copy link
Copy Markdown
Member Author

@graingert I wonder if you have time to review this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

graingert
graingert approved these changes Oct 15, 2023
View reviewed changes

@graingert graingert left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah the old _join_threads was always a noop

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
graingert
graingert reviewed Oct 15, 2023
View reviewed changes
Comment thread Lib/test/test_asyncio/utils.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

gvanrossum added 2 commits October 25, 2023 21:05
@gvanrossum
Merge branch 'main' into asyncio_clear_watcher_threads
2c1974e
@gvanrossum
Raise error if watcher thread won't die
50cab38
@gvanrossum

gvanrossum commented Oct 26, 2023

Copy link
Copy Markdown
Member Author

Assuming this passes I will merge it and backport to 3.12 and 3.11.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

willingc
willingc approved these changes Oct 27, 2023
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Oct 27, 2023
@gvanrossum
gvanrossum merged commit c3bb10c into python:main Oct 27, 2023
@bedevere-app bedevere-app Bot removed the awaiting merge label Oct 27, 2023
@miss-islington-app

miss-islington-app Bot commented Oct 27, 2023

Copy link
Copy Markdown

Thanks @gvanrossum for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@gvanrossum
gvanrossum deleted the asyncio_clear_watcher_threads branch October 27, 2023 22:44
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 27, 2023
@gvanrossum @miss-islington
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (py…
8d9326d
…thonGH-110884)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
(cherry picked from commit c3bb10c)

Co-authored-by: Guido van Rossum <[email protected]>
@bedevere-app

bedevere-app Bot commented Oct 27, 2023

Copy link
Copy Markdown

GH-111412 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 27, 2023
@gvanrossum @miss-islington
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (py…
ba3e29e
…thonGH-110884)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
(cherry picked from commit c3bb10c)

Co-authored-by: Guido van Rossum <[email protected]>
@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 27, 2023
@bedevere-app

bedevere-app Bot commented Oct 27, 2023

Copy link
Copy Markdown

GH-111413 is a backport of this pull request to the 3.11 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.11 only security fixes label Oct 27, 2023
gvanrossum added a commit that referenced this pull request Oct 27, 2023
@miss-islington @gvanrossum
[3.12] gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (G…
2398036
…H-110884) (#111412)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
(cherry picked from commit c3bb10c)

Co-authored-by: Guido van Rossum <[email protected]>
gvanrossum added a commit that referenced this pull request Oct 27, 2023
@miss-islington @gvanrossum
[3.11] gh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (G…
1a01ca4
…H-110884) (#111413)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
(cherry picked from commit c3bb10c)

Co-authored-by: Guido van Rossum <[email protected]>
iritkatriel pushed a commit to iritkatriel/cpython that referenced this pull request Oct 29, 2023
@gvanrossum @iritkatriel
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (py…
2e74589
…thon#110884)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
aisk pushed a commit to aisk/cpython that referenced this pull request Feb 11, 2024
@gvanrossum @aisk
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (py…
f540277
…thon#110884)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@gvanrossum @Glyphack
pythongh-110205: Fix asyncio ThreadedChildWatcher._join_threads() (py…
ecd1749
…thon#110884)

- `ThreadedChildWatcher.close()` is now *officially* a no-op; `_join_threads()` never did anything.
- Threads created by that class are now named `asyncio-waitpid-NNN`.
- `test.test_asyncio.utils.TestCase.close_loop()` now waits for the child watcher's threads, but not forever; if a thread hangs, it raises `RuntimeError`.
@epenet epenet mentioned this pull request Oct 1, 2026
Allow asyncio-waitpid threads in test cleanup check home-assistant/core#183831
Merged
1 of 21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@graingert graingert graingert approved these changes
@willingc willingc willingc approved these changes
@1st1 1st1 Awaiting requested review from 1st1 1st1 is a code owner
@asvetlov asvetlov Awaiting requested review from asvetlov asvetlov is a code owner
@kumaraditya303 kumaraditya303 Awaiting requested review from kumaraditya303 kumaraditya303 is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir topic-asyncio

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@gvanrossum @graingert @willingc @vstinner
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.