FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches by encukou · Pull Request #116805 · python/cpython · GitHub

/ cpython Public

gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches - #116805

Merged
encukou merged 1 commit into
python:mainfrom
encukou:importlib-refleaks
Mar 14, 2024
Merged

gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches#116805
encukou merged 1 commit into
python:mainfrom
encukou:importlib-refleaks

Conversation

encukou commented Mar 14, 2024
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

Thanks to @jaraco for investigation (i.e. the hard part of the fix)

Clearing the inspect caches isn't entirely correct -- see #116804.
This PR is a minimal change to get the buildbots green.

…ar_caches

Co-Authored-By: Jason R. Coombs <jaraco@jaraco.com>

jaraco left a comment
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This whole long function makes me wonder if Python shouldn't prescribe a protocol for any module to provide cache cleanup, e.g. a __cache_clean method. Then there could be a single routine like at the top:

    for mod in sys.modules.values():
        if hasattr(mod, '__warningregistry__'):
            del mod.__warningregistry__
        with suppress(AttributeError):
            mod.__cache_clean()

Regardless, such a refactor would be out of the scope of this issue.

except KeyError:
pass
else:
importlib_metadata.FastPath.__new__.cache_clear()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why not importlib_metadata.MetadataPathFinder().invalidate_caches()? I feel like the latter is likely to be more robust if new caches are created.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

IMO, that'd make it too easy to add unbounded caches, like those in #116804. The refleak tests should catch those :)

encukou added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 14, 2024

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @encukou for commit 7f58006 🤖

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 14, 2024
encukou merged commit bae6579 into python:main Mar 14, 2024
encukou deleted the importlib-refleaks branch March 14, 2024 15:47
encukou added the needs backport to 3.12 only security fixes label Mar 14, 2024

Copy link
Copy Markdown

Thanks @encukou for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 14, 2024
…es in clear_caches (pythonGH-116805)

(cherry picked from commit bae6579)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>

bedevere-app Bot commented Mar 14, 2024

Copy link
Copy Markdown

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

bedevere-app Bot removed the needs backport to 3.12 only security fixes label Mar 14, 2024
encukou added a commit that referenced this pull request Mar 14, 2024
…hes in clear_caches (GH-116805) (GH-116820)

gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches (GH-116805)
(cherry picked from commit bae6579)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
vstinner pushed a commit to vstinner/cpython that referenced this pull request Mar 20, 2024
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL