-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 Awkward errors after fastapi_events setup #5
Comments
It is easy to reproduce with this minimal app import asyncio
import random
from fastapi import FastAPI
from fastapi_events.dispatcher import dispatch
from fastapi_events.handlers.local import local_handler
from fastapi_events.middleware import EventHandlerASGIMiddleware
app = FastAPI()
app.add_middleware(EventHandlerASGIMiddleware, handlers=[local_handler])
@app.get("/healthz")
async def healthz():
dispatch("xyz", payload=None)
await asyncio.sleep(random.randint(1, 5)) Running poetry run uvicorn --loop asyncio --http h11 example.minimal_fastapi_app:app
...
INFO: 127.0.0.1:63106 - "GET /healthz HTTP/1.1" 200 OK
ERROR: Exception in ASGI application
Traceback (most recent call last):
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
await super().__call__(scope, receive, send)
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/fastapi_events/middleware.py", line 29, in __call__
self._teardown_event_store()
File "/Users/e.iskandarov/example/.venv/lib/python3.8/site-packages/fastapi_events/middleware.py", line 40, in _teardown_event_store
event_store.reset(self._token)
ValueError: <Token var=<ContextVar name='fastapi_context' at 0x106b196d0> at 0x106b89200> was created in a different Context and executing wrk -c2 -d30s http://127.0.0.1:8000/healthz LibrariesMacOS 10.14.6
|
the issue persists with |
Hi, @emcpow2, thanks for reporting the issue. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Traces gathered by sentry.io:
Trace I'm seeing in logs
The text was updated successfully, but these errors were encountered: