47
47
# Mutex to protect _cache_initialized and _cache_used.
48
48
_cache_initialized_mutex = threading .Lock ()
49
49
50
+ _UNSUPPORTED_RUNTIMES : set [str ] = set ()
50
51
51
52
def set_once_cache_used (f ) -> None :
52
53
"""One-time setting of _cache_used.
@@ -134,10 +135,13 @@ def _initialize_cache() -> None:
134
135
logger .debug ("Initialized persistent compilation cache at %s" , path )
135
136
136
137
137
- def _get_cache () -> CacheInterface | None :
138
+ def _get_cache (backend ) -> CacheInterface | None :
138
139
# TODO(b/289098047): consider making this an API and changing the callers of
139
140
# get_executable_and_time() and put_executable_and_time() to call get_cache()
140
141
# and passing the result to them.
142
+ if backend .runtime_type in _UNSUPPORTED_RUNTIMES :
143
+ logger .debug ("_get_cache: Unsupported runtime: %s" , backend .runtime_type )
144
+ return None
141
145
if _cache is None :
142
146
_initialize_cache () # initialization is done at most once; see above
143
147
return _cache
@@ -158,9 +162,9 @@ def decompress_executable(executable):
158
162
return zlib .decompress (executable )
159
163
160
164
161
- def is_executable_in_cache (cache_key : str ) -> bool :
165
+ def is_executable_in_cache (backend , cache_key : str ) -> bool :
162
166
"""Checks if the executable is in the cache."""
163
- cache = _get_cache ()
167
+ cache = _get_cache (backend )
164
168
if cache is None :
165
169
return False
166
170
@@ -175,7 +179,7 @@ def get_executable_and_time(
175
179
"""Returns the cached executable and its compilation time if present, or None
176
180
otherwise.
177
181
"""
178
- cache = _get_cache ()
182
+ cache = _get_cache (backend )
179
183
if cache is None :
180
184
logger .debug ("get_executable_and_time: cache is disabled/not initialized" )
181
185
return None , None
@@ -201,7 +205,7 @@ def put_executable_and_time(
201
205
"""Adds the 'executable' and its compilation time to the cache, possibly
202
206
evicting older entries.
203
207
"""
204
- cache = _get_cache ()
208
+ cache = _get_cache (backend )
205
209
if cache is None :
206
210
logger .debug ("put_executable_and_time: cache is disabled/not initialized" )
207
211
return
0 commit comments