Conversation
Signed-off-by: Abhinav Gorrepati <gorrepatiabhinav1@gmail.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13399 +/- ##
=======================================
Coverage 98.99% 98.99%
=======================================
Files 132 132
Lines 49454 49468 +14
Branches 2572 2573 +1
=======================================
+ Hits 48959 48973 +14
Misses 371 371
Partials 124 124
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Merging this PR will improve performance by 9.64%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_simple_web_file_response[ssl-large] |
307.7 ms | 280.6 ms | +9.64% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing AG0708:codex/4647-reentrant-file-response (af230c0) with master (d041d4d)2
Footnotes
-
83 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
-
No successful run was found on
master(77c5108) during the generation of this report, so d041d4d was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "Clarify FileResponse.prepare return valu..." | Re-trigger Greptile |
Signed-off-by: Abhinav Gorrepati <gorrepatiabhinav1@gmail.com>
What do these changes do?
Makes
FileResponse.prepare()return the existing response writer when the response has already been prepared, matchingStreamResponse.prepare()instead of reopening and sending the file a second time. A regression test covers two calls on the same response.Are there changes in behavior for the user?
Yes. Applications may explicitly await
FileResponse.prepare()before returning the response—for example, so a temporary file can then be removed—without aiohttp preparing and sending it again. First-call behavior is unchanged.Is it a substantial burden for the maintainers to support this?
No. The guard delegates the already-prepared case to the base implementation and adds no new state or dependency.
Related issue number
Fixes #4647.
Checklist
CONTRIBUTORS.txtin alphabetical orderCHANGES/4647.feature.rstLocal validation
Drafted with OpenAI Codex (GPT-5); reviewed by @AG0708.