You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: try multiple times to get win32 version to handle flakes (#2814)
The Google tensorflow/jax devinfra team reported that Windows 2022 with
Python 3.12.8
has a tendency to be flaky when calling the platform.win32 APIs. I'm
very certain I
saw similar behavior in the past myself.
To fix, just call the APIs a couple times; it seems to fix itself.
cc @vam-google
# removed from common Win32 file and directory functions.
47
47
# Related doc: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later
48
48
import platform
49
-
if platform.win32_ver()[1] >= '10.0.14393':
49
+
win32_version = None
50
+
# Windows 2022 with Python 3.12.8 gives flakey errors, so try a couple times.
51
+
for _ in range(3):
52
+
try:
53
+
win32_version = platform.win32_ver()[1]
54
+
break
55
+
except (ValueError, KeyError):
56
+
pass
57
+
if win32_version and win32_version >= '10.0.14393':
50
58
return path
51
59
52
60
# import sysconfig only now to maintain python 2.6 compatibility
# Related doc: https://docs.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=cmd#enable-long-paths-in-windows-10-version-1607-and-later
59
59
importplatform
60
60
61
-
ifplatform.win32_ver()[1] >="10.0.14393":
61
+
win32_version=None
62
+
# Windows 2022 with Python 3.12.8 gives flakey errors, so try a couple times.
63
+
for_inrange(3):
64
+
try:
65
+
win32_version=platform.win32_ver()[1]
66
+
break
67
+
except (ValueError, KeyError):
68
+
pass
69
+
ifwin32_versionandwin32_version>='10.0.14393':
62
70
returnpath
63
71
64
72
# import sysconfig only now to maintain python 2.6 compatibility
0 commit comments