Closed bisgaard-itis closed 2 weeks ago
Attention: Patch coverage is 31.53153%
with 76 lines
in your changes missing coverage. Please review.
Project coverage is 87.5%. Comparing base (
cafbf96
) to head (3964920
). Report is 266 commits behind head on master.
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
What do these changes do?
The problem (in a nutshell) which this PR tries to solve
When we run our endpoints via
run_sequentially_in_context
they are run in a different context (in the sense of https://docs.python.org/3/library/contextvars.html#contextvars.Context). This has several downsides. One is that tools for monitoring concurrent code (such as pyinstrument's profiler) are not compatible with. The way they track the handling of a request is by tracking the context. A second downside is thatrun_sequentially_in_context
creates anasyncio
task which (potentially) handles several requests. However, when an asyncio task is created it "inherrits" a copy of the context in which it is created. Because of this one request can influence how another request is handled: If the task is created when the first request is handled, then the second request will be handled within (a copy of) the context of the first request. That seems unfortunate. See e.g. https://stackoverflow.com/a/63131230Related issue/s
How to test
Dev-ops checklist