Commit 6827fe5
committed
Fix thread affinity in production request pipeline
Consolidate the request pipeline into a single executor call so that
request_started, before-middleware, view dispatch, after-middleware,
and request_finished all run on the same thread. This preserves
thread-local DB connection assumptions (threading.local).
Move request_finished from response.close() into the pipeline so it
fires on the correct thread. The test client now calls the sync
pipeline directly, removing the need for _SameThreadExecutor and
unconditional asyncio.run().1 parent e47efeb commit 6827fe5
File tree
3 files changed
+193
-221
lines changed- plain/plain
- http
- internal/handlers
- test
3 files changed
+193
-221
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
135 | 134 | | |
136 | 135 | | |
137 | 136 | | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | 137 | | |
142 | 138 | | |
143 | 139 | | |
| |||
320 | 316 | | |
321 | 317 | | |
322 | 318 | | |
323 | | - | |
324 | 319 | | |
325 | 320 | | |
326 | 321 | | |
| |||
0 commit comments