pre-commit-ci-lite[bot]
3 weeks ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
5 additions and
1 deletions
-
fastapi/routing.py
|
|
|
@ -258,7 +258,11 @@ class EndpointContext(TypedDict, total=False): |
|
|
|
# Use a WeakKeyDictionary instead of a standard dict to prevent memory leaks |
|
|
|
# and cache collisions when endpoints are dynamically created and destroyed. |
|
|
|
# This cache will only be used for the fallback "slow path". |
|
|
|
_endpoint_context_cache: weakref.WeakKeyDictionary[Any, EndpointContext] = weakref.WeakKeyDictionary() |
|
|
|
_endpoint_context_cache: weakref.WeakKeyDictionary[Any, EndpointContext] = ( |
|
|
|
weakref.WeakKeyDictionary() |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
def _extract_endpoint_context(func: Any) -> EndpointContext: |
|
|
|
"""Extract endpoint context with caching to avoid repeated file I/O.""" |
|
|
|
|
|
|
|
|