summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorKyle Stanley <aeros167@gmail.com>2020-05-31 07:07:04 (GMT)
committerGitHub <noreply@github.com>2020-05-31 07:07:04 (GMT)
commit2b201369b435a4266bda5b895e3b615dbe28ea6e (patch)
tree75306b15a42274e929b3286f4a74368b983f205c /Lib/asyncio
parent007bb06a2de9e64fa978f5dd9131d0100227b4cf (diff)
downloadcpython-2b201369b435a4266bda5b895e3b615dbe28ea6e.zip
cpython-2b201369b435a4266bda5b895e3b615dbe28ea6e.tar.gz
cpython-2b201369b435a4266bda5b895e3b615dbe28ea6e.tar.bz2
Fix asyncio.to_thread() documented return type (GH-20547)
When I wrote the documentation for `asyncio.to_thread()`, I mistakenly assumed that `return await loop.run_in_executor(...)` within an async def function would return a Future. In reality, it returns a coroutine. This likely won't affect typical usage of `asyncio.to_thread()`, but it's important for the documentation to be correct here. In general, we also tend to avoid returning futures from high-level APIs in asyncio.
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/threads.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/asyncio/threads.py b/Lib/asyncio/threads.py
index 51e0ba9..34b7513 100644
--- a/Lib/asyncio/threads.py
+++ b/Lib/asyncio/threads.py
@@ -17,7 +17,7 @@ async def to_thread(func, /, *args, **kwargs):
allowing context variables from the main thread to be accessed in the
separate thread.
- Return an asyncio.Future which represents the eventual result of *func*.
+ Return a coroutine that can be awaited to get the eventual result of *func*.
"""
loop = events.get_running_loop()
ctx = contextvars.copy_context()