From 94f4d87aeb4d2d7bddcb4c3aad4f62a727ac91ee Mon Sep 17 00:00:00 2001 From: Kumar Aditya Date: Tue, 18 Mar 2025 00:52:57 +0530 Subject: gh-131325: fix sendfile fallback implementation to drain data after writing to transport (#131376) --- Lib/asyncio/base_events.py | 2 +- Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 546361f..ff63639 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1295,8 +1295,8 @@ class BaseEventLoop(events.AbstractEventLoop): read = await self.run_in_executor(None, file.readinto, view) if not read: return total_sent # EOF - await proto.drain() transp.write(view[:read]) + await proto.drain() total_sent += read finally: if total_sent > 0 and hasattr(file, 'seek'): diff --git a/Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst b/Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst new file mode 100644 index 0000000..6c1f64e --- /dev/null +++ b/Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst @@ -0,0 +1 @@ +Fix sendfile fallback implementation to drain data after writing to transport in :mod:`asyncio`. -- cgit v0.12