-
-
Notifications
You must be signed in to change notification settings - Fork 944
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
refactor: update request-id recipe to use contextvars #2404
base: master
Are you sure you want to change the base?
Conversation
Migrate the request-id handling from threading.local() to contextvars to improve compatibility with async coroutines and avoid issues with threading. This change ensures that request-id is properly tracked in asynchronous environments, providing more robust handling in both sync and async contexts. Previously, threading.local() was used, which does not handle coroutines effectively. By using contextvars, we ensure that the request-id remains consistent across async calls. Closes falconry#2260
Add tests to verify that request_id is unique per request and correctly set in response headers. Tests include checks for isolation in async calls and persistence in synchronous requests. Related to issue falconry#2260
Add tests to verify that request_id is unique per request and correctly set in response headers. Tests include checks for isolation in async calls and persistence in synchronous requests. Related to issue falconry#2260
I wanted to apologize for the confusion with my pull request. This is my first time contributing to a public repository, and I made a mistake with the process. I had previously opened a PR with the changes, but I accidentally closed it and am unable to reopen it. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2404 +/- ##
===========================================
- Coverage 100.00% 98.27% -1.73%
===========================================
Files 64 64
Lines 7726 7726
Branches 1071 1071
===========================================
- Hits 7726 7593 -133
- Misses 0 115 +115
- Partials 0 18 +18 ☔ View full report in Codecov by Sentry. |
Summary of Changes
Migrate the request-id handling from threading.local() to contextvars to improve compatibility with async coroutines and avoid issues with threading. This change ensures that request-id is properly tracked in asynchronous environments, providing more robust handling in both sync and async contexts.
Previously, threading.local() was used, which does not handle coroutines effectively. By using contextvars, we ensure that the request-id remains consistent across async calls.
Related Issues
Closes #2260.