[3.8] Use threadpool for reading from file in sendfile fallback mode (GH-14076) (GH-14102)
(cherry picked from commit 0237265e8287141c40faa8719da3a2d21d511d0d)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index 90de858..14b80bd 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1141,7 +1141,7 @@
if blocksize <= 0:
return total_sent
view = memoryview(buf)[:blocksize]
- read = file.readinto(view)
+ read = await self.run_in_executor(None, file.readinto, view)
if not read:
return total_sent # EOF
await proto.drain()