MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _retrieve_tracker_rec

Method _retrieve_tracker_rec

lib/sqlalchemy/sql/lambdas.py:220–314  ·  view source on GitHub ↗
(self, fn, apply_propagate_attrs, opts)

Source from the content-addressed store, hash-verified

218 apply_propagate_attrs._propagate_attrs = propagate_attrs
219
220 def _retrieve_tracker_rec(self, fn, apply_propagate_attrs, opts):
221 lambda_cache = opts.lambda_cache
222 if lambda_cache is None:
223 lambda_cache = _closure_per_cache_key
224
225 tracker_key = self.tracker_key
226
227 fn = self.fn
228 closure = fn.__closure__
229 tracker = AnalyzedCode.get(
230 fn,
231 self,
232 opts,
233 )
234
235 bindparams: List[BindParameter[Any]]
236 self._resolved_bindparams = bindparams = []
237
238 if self.parent_lambda is not None:
239 parent_closure_cache_key = self.parent_lambda.closure_cache_key
240 else:
241 parent_closure_cache_key = ()
242
243 cache_key: Union[Tuple[Any, ...], Literal[CacheConst.NO_CACHE]]
244
245 if parent_closure_cache_key is not _cache_key.NO_CACHE:
246 anon_map = visitors.anon_map()
247 cache_key = tuple(
248 [
249 getter(closure, opts, anon_map, bindparams)
250 for getter in tracker.closure_trackers
251 ]
252 )
253
254 if _cache_key.NO_CACHE not in anon_map:
255 cache_key = parent_closure_cache_key + cache_key
256
257 self.closure_cache_key = cache_key
258
259 rec = lambda_cache.get(tracker_key + cache_key)
260 else:
261 cache_key = _cache_key.NO_CACHE
262 rec = None
263
264 else:
265 cache_key = _cache_key.NO_CACHE
266 rec = None
267
268 self.closure_cache_key = cache_key
269
270 if rec is None:
271 if cache_key is not _cache_key.NO_CACHE:
272 with AnalyzedCode._generation_mutex:
273 key = tracker_key + cache_key
274 if key not in lambda_cache:
275 rec = AnalyzedFunction(
276 tracker, self, apply_propagate_attrs, fn
277 )

Callers 2

__init__Method · 0.95
__init__Method · 0.80

Calls 5

_invoke_user_fnMethod · 0.95
AnalyzedFunctionClass · 0.85
NonAnalyzedFunctionClass · 0.85
_with_valueMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected