From: Andrew Svetlov Date: Sat, 15 Jun 2019 11:55:52 +0000 (+0300) Subject: [3.8] Use threadpool for reading from file in sendfile fallback mode (GH-14076) ... X-Git-Tag: v3.8.0b2~127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b6ff2cd8c5bc1d4e4e61b9138436b507b31c6c7a;p=python [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 --- diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index 90de8587a3..14b80bdda9 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1141,7 +1141,7 @@ class BaseEventLoop(events.AbstractEventLoop): 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() diff --git a/Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst b/Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst new file mode 100644 index 0000000000..7cdc56a72c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst @@ -0,0 +1 @@ +Use threadpool for reading from file for sendfile fallback mode.