Python 3.14+platformfunction
platform.invalidate_caches()
system and machine
Clears the platform module's internal cache so that uname(), node() and others query the system again (3.14+).
Syntax
platform.invalidate_caches()
The module remembers answers from the first call, so if the hostname changes while the program runs (common for long-lived services and containers), node() keeps returning the old value. invalidate_caches() is the only supported way to see the new value without restarting. Before 3.14 there was no such way.
Examples
import platform
before = platform.uname()
print(platform.uname() is before) # → True — ответ взят из кэша
platform.invalidate_caches()
print(platform.uname() is before) # → False — система опрошена заново
See also
Open in the full glossarydocs.python.orgReport an inaccuracy