https://github.com/python/cpython/commit/c1faeadd82933d86030a903ba4b98f599fc65284
commit: c1faeadd82933d86030a903ba4b98f599fc65284
branch: 3.12
author: Miss Islington (bot) <31488909+miss-isling...@users.noreply.github.com>
committer: kumaraditya303 <kumaradi...@python.org>
date: 2025-03-17T19:40:43Z
summary:

[3.12] gh-131325: fix sendfile fallback implementation to drain data after 
writing to transport (GH-131376) (#131378)

gh-131325: fix sendfile fallback implementation to drain data after writing to 
transport (GH-131376)
(cherry picked from commit 94f4d87aeb4d2d7bddcb4c3aad4f62a727ac91ee)

Co-authored-by: Kumar Aditya <kumaradi...@python.org>

files:
A Misc/NEWS.d/next/Library/2025-03-17-18-50-39.gh-issue-131325.wlasMF.rst
M Lib/asyncio/base_events.py

diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 136c1631822427..813a85dbc39d57 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1264,8 +1264,8 @@ async def _sendfile_fallback(self, transp, file, offset, 
count):
                 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 00000000000000..6c1f64eee6ad02
--- /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`.

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to