-
Notifications
You must be signed in to change notification settings - Fork 166
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
Error using Processor as context manager in async method: "popped unexpected object" #368
Comments
Could you try to make a minimal, reproducible example? Some thoughts:
|
@RazerM Made a minimal reproducible example: https://github.com/aiguofer/async_logbook_error_example/ I'll play around with some logging to see what happens! |
Hmm ok adding some logging and comparing results when using
I see that the non-async version handles all requests independently with no concurrency in the worker, while the async version handles all the permission checks concurrently, so everything gets pushed first before anything gets popped. Async:
Sync:
I take it the logbook Processor just doesn't play well while async if each concurrent worker needs to have a different Processor? |
I think you need to do with logbook.Processor(self._inject_logging_context).contextbound():
... |
ohhhh that did it!!! thanks so much! It'd be great to have a breakdown of the different stacks (greenlet, async context, thread, and application) in https://logbook.readthedocs.io/en/stable/stacks.html |
We have a FastAPI/Strawberry app that we ensure proper tracing using a custom Strawberry schema (there's a set of values we inject into every log using a Processor). We recently did some work to do some async work in the permissions handler, and now we're running into some errors:
Our
telemetry/schema.py
file looks like:And our
context
class looks like:My guess is that there's some issues going on with the async
execute
and the context manager from theProcessor
. I'm not super familiar with async coroutines in Python, but shouldProcessor
also implement__aenter__
and__aexit__
so we can have anasync with
for theasync execute
?The text was updated successfully, but these errors were encountered: