[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5

yury.selivanov python-checkins at python.org
Mon Nov 16 15:13:00 EST 2015


https://hg.python.org/cpython/rev/06820c2bd0b6
changeset: 99179:06820c2bd0b6
parent: 99176:152306d1d2b5
parent: 99178:4f8c871616e8
user: Yury Selivanov <yselivanov at sprymix.com>
date: Mon Nov 16 15:12:54 2015 -0500
summary:
 Merge 3.5
files:
 Lib/asyncio/tasks.py | 13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -93,6 +93,7 @@
 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 @@
 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 @@
 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.
 
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /