-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hi,
I am using flaat in a FastAPI application. The application is a long running server exposing a set of REST API.
There is a client which periocally concacts the application. It provides an access_token and it has a refresh token with a long expiration time.
Unfortunately, after 1 month (more or less) I periodically have this problem. When this happens the client can't perform any operation on the server and the solution is usually to restart the application. Instead other clients can query the server.
I can't understand what is causing this and how can I eventually configure/clear the cache.
Here the output:
[2025-06-23 05:48:23 +0000] [7] [ERROR] Exception in ASGI application
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/uvicorn/protocols/http/httptools_impl.py", line 409, in run_asgi
result = await app( # type: ignore[func-returns-value]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
return await self.app(scope, receive, send)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/applications.py", line 116, in __call__
await self.middleware_stack(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
raise exc
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
await app(scope, receive, sender)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 746, in __call__
await route.handle(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 459, in handle
await self.app(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/fastapi/applications.py", line 1054, in __call__
await super().__call__(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/applications.py", line 116, in __call__
await self.middleware_stack(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
raise exc
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
await self.app(scope, receive, _send)
File "/root/.local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
raise exc
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
await app(scope, receive, sender)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 746, in __call__
await route.handle(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
await self.app(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 75, in app
await wrap_app_handling_exceptions(app, request)(scope, receive, send)
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 55, in wrapped_app
raise exc
File "/root/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 44, in wrapped_app
await app(scope, receive, sender)
File "/root/.local/lib/python3.11/site-packages/starlette/routing.py", line 70, in app
response = await func(request)
^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/fastapi/routing.py", line 285, in app
raise e
File "/root/.local/lib/python3.11/site-packages/fastapi/routing.py", line 275, in app
solved_result = await solve_dependencies(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/fastapi/dependencies/utils.py", line 600, in solve_dependencies
solved = await run_in_threadpool(call, **sub_values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/starlette/concurrency.py", line 35, in run_in_threadpool
return await anyio.to_thread.run_sync(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
return await future
^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/anyio/_backends/_asyncio.py", line 859, in run
result = context.run(func, *args)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/my_app/auth.py", line 62, in strict_security
user_infos = flaat.get_user_infos_from_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/flaat/__init__.py", line 234, in get_user_infos_from_request
user_infos = self.get_user_infos_from_access_token(access_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/cachetools/__init__.py", line 739, in wrapper
cache[k] = v
~~~~~^^^
File "/root/.local/lib/python3.11/site-packages/cachetools/__init__.py", line 217, in __setitem__
cache_setitem(self, key, value)
File "/root/.local/lib/python3.11/site-packages/cachetools/__init__.py", line 79, in __setitem__
self.popitem()
File "/root/.local/lib/python3.11/site-packages/cachetools/__init__.py", line 231, in popitem
return (key, self.pop(key))
^^^^^^^^^^^^^
File "/root/.local/lib/python3.11/site-packages/cachetools/__init__.py", line 113, in pop
value = self[key]
~~~~^^^^^
File "/root/.local/lib/python3.11/site-packages/flaat/caches.py", line 20, in __getitem__
_fail("Cache entry has expired")
File "/root/.local/lib/python3.11/site-packages/flaat/caches.py", line 13, in _fail
raise KeyError(msg)
KeyError: 'Cache entry has expired'
Metadata
Metadata
Assignees
Labels
No labels