summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-01-04 02:03:34 +0100
committerVictor Stinner <victor.stinner@gmail.com>2014-01-04 02:03:34 +0100
commit3c5af1dbdd56ad60a1def806012c39a2668e7648 (patch)
treefff9fa74cb8c14e693b3df749621831a40006f69
parent6f9e03cb0f1bba24dfb68dfe83507933791ecac6 (diff)
downloadtrollius-3c5af1dbdd56ad60a1def806012c39a2668e7648.tar.gz
Remove Future._blocking, yield-from cannot be used
-rw-r--r--asyncio/futures.py3
-rw-r--r--asyncio/tasks.py29
2 files changed, 5 insertions, 27 deletions
diff --git a/asyncio/futures.py b/asyncio/futures.py
index 28f7866..5e0077c 100644
--- a/asyncio/futures.py
+++ b/asyncio/futures.py
@@ -147,8 +147,6 @@ class Future(object):
_exception = None
_loop = None
- _blocking = False # proper use of future (yield vs yield from)
-
_tb_logger = None
def __init__(self, loop=None):
@@ -346,7 +344,6 @@ class Future(object):
@coroutine
def __iter__(self):
if not self.done():
- self._blocking = True
yield self # This tells Task to wait for completion.
assert self.done(), "yield wasn't used with future"
raise Return(self.result()) # May raise too.
diff --git a/asyncio/tasks.py b/asyncio/tasks.py
index fcea4db..0538f63 100644
--- a/asyncio/tasks.py
+++ b/asyncio/tasks.py
@@ -217,33 +217,14 @@ class Task(futures.Future):
if isinstance(result, futures.Future):
# Yielded Future must come from Future.__iter__().
- # FIXME
- if True: #result._blocking:
- result._blocking = False
- result.add_done_callback(self._wakeup)
- self._fut_waiter = result
- if self._must_cancel:
- if self._fut_waiter.cancel():
- self._must_cancel = False
- else:
- # FIXME
- self._loop.call_soon(
- self._step, None,
- RuntimeError(
- 'yield was used instead of yield from '
- 'in task {!r} with {!r}'.format(self, result)))
+ result.add_done_callback(self._wakeup)
+ self._fut_waiter = result
+ if self._must_cancel:
+ if self._fut_waiter.cancel():
+ self._must_cancel = False
elif result is None:
# Bare yield relinquishes control for one event loop iteration.
self._loop.call_soon(self._step)
- elif inspect.isgenerator(result):
- # Yielding a generator is just wrong.
- # FIXME
- self._loop.call_soon(
- self._step, None,
- RuntimeError(
- 'yield was used instead of yield from for '
- 'generator in task {!r} with {}'.format(
- self, result)))
else:
# Yielding something else is an error.
self._loop.call_soon(