]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Use threadpool for reading from file in sendfile fallback mode (GH-14076)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 15 Jun 2019 11:27:10 +0000 (04:27 -0700)
committerGitHub <noreply@github.com>
Sat, 15 Jun 2019 11:27:10 +0000 (04:27 -0700)
(cherry picked from commit 0237265e8287141c40faa8719da3a2d21d511d0d)

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/asyncio/base_events.py
Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst [new file with mode: 0644]

index a736d01d6f37844911ace7001be588e76a220fce..a9660ca1089ca4f806208637f19d08b551378ccb 100644 (file)
@@ -1078,7 +1078,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 (file)
index 0000000..7cdc56a
--- /dev/null
@@ -0,0 +1 @@
+Use threadpool for reading from file for sendfile fallback mode.