Open vytas7 opened 3 months ago
I don't think there is any need to use threadlocal or contextvar. just use req
or resp
context
.
re-reading all that page it proposes several approaches. so yes, context var is better than threadlocal
Indeed, using global thread-locals is usually not a very bright idea and it leads to a spaghetti code base. But sometimes, particularly when working with a code base migrated from another framework that builds on this paradigm, or when very deep inside nested code, it might be a useful escape hatch.
Hello, I would like to work on this issue. Please let me know if there is any information that I should know before proceeding. Thank you.
Hi @EricGoulart! We are glad to hear, sure, go ahead! You can skim through our docs on how to contribute to Falcon.
Regarding the issue itself, I hope the description is clear enough, but just ask here or on Gitter if you run into any problems.
The recipe that needs to be updated is this file: docs/user/recipes/request-id.rst
(but it also includes snippets from small Python files).
You can render out the docs with tox -e docs
. Then open docs/_build/html/user/recipes/request-id.html
in your browser.
Hello, just wanto to say sorry about that, It`s my first time contribuiting to a public repository and I am making some mistakes.
contextvars
is a newer module in the stdlib (3.7+) that is more advanced thantheading.local()
as it not only understand threads, but alsoasyncio
coroutines, etc.Update the Request ID Logging recipe to use
contextvars
.Edit: also add tests for this recipe.