Skip to content

Add platform.invalidate_caches for invalidating cached results #122549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
picnixz opened this issue Aug 1, 2024 · 3 comments
Closed

Add platform.invalidate_caches for invalidating cached results #122549

picnixz opened this issue Aug 1, 2024 · 3 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@picnixz
Copy link
Member

picnixz commented Aug 1, 2024

Feature or enhancement

Proposal:

In #122525, it was observed that many functions of the platform module use cached results. This is, in practice, preferrable, but it should also be possible, if needed, to invalidate cached results. One use case is when the host name changes (i.e., one of the uname() components change).

Has this already been discussed elsewhere?

No response given

Links to previous discussion of this feature:

No response

Linked PRs

@picnixz picnixz added type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels Aug 1, 2024
@picnixz picnixz changed the title Add platform.invalidate_caches for invalidating cached results (follow-up of #122525) Add platform.invalidate_caches for invalidating cached results Aug 1, 2024
@kashav
Copy link

kashav commented Aug 1, 2024

One use case is when the host name changes (i.e., one of the uname() components change).

Mostly out of curiosity - is there any way to watch for host name change?

@picnixz
Copy link
Member Author

picnixz commented Aug 1, 2024

Well.. you could have a task that runs every second and checks whether the host name changed or not. socket.gethostname gives you the runtime one, so you'll need to query it every second.

vstinner pushed a commit that referenced this issue Nov 15, 2024
Allow to invalidate platform's cached results.
@picnixz
Copy link
Member Author

picnixz commented Nov 15, 2024

Completed in 612ac28.

@picnixz picnixz closed this as completed Nov 15, 2024
picnixz added a commit to picnixz/cpython that referenced this issue Dec 8, 2024
Allow to invalidate platform's cached results.
ebonnal pushed a commit to ebonnal/cpython that referenced this issue Jan 12, 2025
Allow to invalidate platform's cached results.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants