From 8acf02f63325d2dbac4f8438481665f7e892bb01 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 21 May 2013 08:34:55 -0700 Subject: [PATCH] Add async(). See https://codereview.appspot.com/9245047/ --- pep-3156.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pep-3156.txt b/pep-3156.txt index c718c4fb8..b5845f269 100644 --- a/pep-3156.txt +++ b/pep-3156.txt @@ -260,8 +260,7 @@ methods, and still conform to the other methods.) - Basic callbacks: ``call_soon()``, ``call_later()``, ``call_at()``. - Thread interaction: ``call_soon_threadsafe()``, - ``wrap_future()``, ``run_in_executor()``, - ``set_default_executor()``. + ``run_in_executor()``, ``set_default_executor()``. - Internet name lookups: ``getaddrinfo()``, ``getnameinfo()``. @@ -903,7 +902,13 @@ However the current PEP strives to have no dependencies beyond Python 3.3, so changes to ``concurrent.futures.Future`` are off the table for now. -There is one public function related to Futures. It is: +There are some public functions related to Futures: + +- ``async(arg)``. This takes an argument that is either a coroutine + object or a Future (i.e., anything you can use with ``yield from``) + and returns a Future. If the argument is a Future, it is returned + unchanged; if it is a coroutine object, it wraps it in a Task + (remember that ``Task`` is a subclass of ``Future``). - ``wrap_future(future)``. This takes a PEP 3148 Future (i.e., an instance of ``concurrent.futures.Future``) and returns a Future