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-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches by encukou · Pull Request #116805 · python/cpython

Conversation

@encukou

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

Uh oh!

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

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.

  • Issue: With #116680, test_importlib started leaking on refleaks #116731

Sorry, something went wrong.

Uh oh!

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

jaraco reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@encukou @jaraco
116731: libregrtest: Clear inspect & importlib.metadata caches in cle…
7f58006
…ar_caches

Co-Authored-By: Jason R. Coombs <[email protected]>
@bedevere-app bedevere-app Bot added the awaiting core review label Mar 14, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Mar 14, 2024
With #116680, test_importlib started leaking on refleaks #116731
Closed
@encukou encukou added the skip news label Mar 14, 2024
jaraco
jaraco approved these changes Mar 14, 2024
View reviewed changes

@jaraco jaraco left a comment •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

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.

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.

Sorry, something went wrong.

Uh oh!

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

encukou reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread Lib/test/libregrtest/utils.py
except KeyError:
pass
else:
importlib_metadata.FastPath.__new__.cache_clear()

@jaraco jaraco Mar 14, 2024

Copy link
Copy Markdown
Member

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.

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

Sorry, something went wrong.

Uh oh!

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

All reactions

@encukou encukou Mar 14, 2024

Copy link
Copy Markdown
Member Author

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.

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

Sorry, something went wrong.

Uh oh!

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

jaraco reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting core review labels Mar 14, 2024
@encukou encukou added the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 14, 2024
@bedevere-bot

bedevere-bot commented 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.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Mar 14, 2024
@jaraco jaraco mentioned this pull request Mar 14, 2024
gh-116731: Fix refleaks in importlib tests #116763
Closed
@encukou
encukou merged commit bae6579 into python:main Mar 14, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Mar 14, 2024
@encukou
encukou deleted the importlib-refleaks branch March 14, 2024 15:47
@encukou encukou added the needs backport to 3.12 only security fixes label Mar 14, 2024
@miss-islington-app

miss-islington-app Bot commented Mar 14, 2024

Copy link
Copy Markdown

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

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 Mar 14, 2024
@encukou @jaraco @miss-islington
pythongh-116731: libregrtest: Clear inspect & importlib.metadata cach…
e61adc5
…es in clear_caches (pythonGH-116805)

(cherry picked from commit bae6579)

Co-authored-by: Petr Viktorin <[email protected]>
Co-authored-by: Jason R. Coombs <[email protected]>
@bedevere-app

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.

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.12 only security fixes label Mar 14, 2024
encukou added a commit that referenced this pull request Mar 14, 2024
@miss-islington @encukou @jaraco
[3.12] gh-116731: libregrtest: Clear inspect & importlib.metadata cac…
9d08e14
…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 <[email protected]>
Co-authored-by: Jason R. Coombs <[email protected]>
vstinner pushed a commit to vstinner/cpython that referenced this pull request Mar 20, 2024
@encukou @jaraco @vstinner
pythongh-116731: libregrtest: Clear inspect & importlib.metadata cach…
31553e0
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <[email protected]>
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 25, 2024
@encukou @jaraco @adorilson
pythongh-116731: libregrtest: Clear inspect & importlib.metadata cach…
7068c6a
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <[email protected]>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@encukou @jaraco @diegorusso
pythongh-116731: libregrtest: Clear inspect & importlib.metadata cach…
9d4b131
…es in clear_caches (pythonGH-116805)

Co-authored-by: Jason R. Coombs <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jaraco jaraco jaraco approved these changes

Uh oh!

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

Assignees

No one assigned

Labels

skip news

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.

3 participants

@encukou @bedevere-bot @jaraco
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.