summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/tasks.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-05-12 02:27:25 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-05-12 02:27:25 (GMT)
commit1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0 (patch)
treed76885ce449761c6dd9893446f359a03327ed6d5 /Lib/asyncio/tasks.py
parentd7e19bb566889343f39c34c98bca4d6db61b53d7 (diff)
downloadcpython-1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0.zip
cpython-1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0.tar.gz
cpython-1af2bf75a2f816eaaf8353eaab8b6dcfee0064c0.tar.bz2
asyncio: Support PEP 492. Issue #24017.
Diffstat (limited to 'Lib/asyncio/tasks.py')
-rw-r--r--Lib/asyncio/tasks.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index f617b62..fcb3833 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -11,6 +11,7 @@ import functools
import inspect
import linecache
import sys
+import types
import traceback
import warnings
import weakref
@@ -73,7 +74,10 @@ class Task(futures.Future):
super().__init__(loop=loop)
if self._source_traceback:
del self._source_traceback[-1]
- self._coro = iter(coro) # Use the iterator just in case.
+ if coro.__class__ is types.GeneratorType:
+ self._coro = coro
+ else:
+ self._coro = iter(coro) # Use the iterator just in case.
self._fut_waiter = None
self._must_cancel = False
self._loop.call_soon(self._step)
@@ -236,7 +240,7 @@ class Task(futures.Future):
elif value is not None:
result = coro.send(value)
else:
- result = next(coro)
+ result = coro.send(None)
except StopIteration as exc:
self.set_result(exc.value)
except futures.CancelledError as exc: