[3.12] gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105) (GH-116120)

gh-116103: Prevent error in WindowsLoadTracker.__del__ on permission error (GH-116105)
(cherry picked from commit 186fa93876)


gh-116103: Prevent error in WindowsLoadTracker.__del__ if there was a permission error

Co-authored-by: Petr Viktorin <encukou@gmail.com>
This commit is contained in:
Miss Islington (bot) 2024-02-29 15:43:05 +01:00 committed by GitHub
parent 6359141867
commit 845123d641
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -24,6 +24,10 @@ class WindowsLoadTracker():
"""
def __init__(self):
# make __del__ not fail if pre-flight test fails
self._running = None
self._stopped = None
# Pre-flight test for access to the performance data;
# `PermissionError` will be raised if not allowed
winreg.QueryInfoKey(winreg.HKEY_PERFORMANCE_DATA)