[Python-checkins] Use threadpool for reading from file in sendfile fallback mode (GH-14076)
Miss Islington (bot)
webhook-mailer at python.org
Sat Jun 15 07:27:14 EDT 2019
https://github.com/python/cpython/commit/5e97450d83d4f4240315f46419686ec193273e13
commit: 5e97450d83d4f4240315f46419686ec193273e13
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-06-15T04:27:10-07:00
summary:
Use threadpool for reading from file in sendfile fallback mode (GH-14076)
(cherry picked from commit 0237265e8287141c40faa8719da3a2d21d511d0d)
Co-authored-by: Andrew Svetlov <andrew.svetlov at gmail.com>
files:
A Misc/NEWS.d/next/Library/2019-06-14-13-30-47.bpo-37280.Fxur0F.rst
M Lib/asyncio/base_events.py
diff --git a/Lib/asyncio/base_events.py b/Lib/asyncio/base_events.py
index a736d01d6f37..a9660ca1089c 100644
--- a/Lib/asyncio/base_events.py
+++ b/Lib/asyncio/base_events.py
@@ -1078,7 +1078,7 @@ def _check_sendfile_params(self, sock, 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 000000000000..7cdc56a72ce4
--- /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.
More information about the Python-checkins
mailing list