From c33e19becfa63d616dee7aaf8ba0ed97bf6b9a2a Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Fri, 14 Jun 2019 13:31:09 +0300 Subject: [PATCH] Use threadpool for reading from file in sendfile fallback mode --- Lib/asyncio/base_events.py | 2 +- .../next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py index e0025397fa8a85..b120a0da05096b 100644 --- a/Lib/asyncio/base_events.py +++ b/Lib/asyncio/base_events.py @@ -1141,7 +1141,7 @@ async def _sendfile_fallback(self, transp, file, offset, count): 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 00000000000000..7cdc56a72ce4f6 --- /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.