summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-11-16 20:12:54 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-11-16 20:12:54 (GMT)
commit43b53091f08204c7aa5f539697d75c99ac4cb96f (patch)
treec43ee43a60bbf827f655cacf789c0e74cd4c01ac /Lib
parentcaf6452af2844efdc44ec63b6a7a7f578ebcc200 (diff)
parentcfff959c07428001cf961fcf95e5ef10256ae8c2 (diff)
downloadcpython-43b53091f08204c7aa5f539697d75c99ac4cb96f.zip
cpython-43b53091f08204c7aa5f539697d75c99ac4cb96f.tar.gz
cpython-43b53091f08204c7aa5f539697d75c99ac4cb96f.tar.bz2
Merge 3.5
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/tasks.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
index 77a93e0..21940f6 100644
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -93,6 +93,7 @@ class Task(futures.Future):
futures.Future.__del__(self)
def _repr_info(self):
+ # Private method, do not use it.
info = super()._repr_info()
if self._must_cancel:
@@ -221,6 +222,7 @@ class Task(futures.Future):
return True
def _step(self, value=None, exc=None):
+ # Private method, do not use it.
assert not self.done(), \
'_step(): already done: {!r}, {!r}, {!r}'.format(self, value, exc)
if self._must_cancel:
@@ -284,13 +286,20 @@ class Task(futures.Future):
self = None # Needed to break cycles when an exception occurs.
def _wakeup(self, future):
+ # Private method, do not use it.
try:
- value = future.result()
+ future.result()
except Exception as exc:
# This may also be a cancellation.
self._step(None, exc)
else:
- self._step(value, None)
+ # Don't pass the value of `future.result()` explicitly,
+ # as `Future.__iter__` and `Future.__await__` don't need it.
+ # If we call `_step(value, None)` instead of `_step()`,
+ # Python eval loop would use `.send(value)` method call,
+ # instead of `__next__()`, which is slower for futures
+ # that return non-generator iterators from their `__iter__`.
+ self._step()
self = None # Needed to break cycles when an exception occurs.