summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/futures.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/futures.py')
-rw-r--r--Lib/asyncio/futures.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/asyncio/futures.py b/Lib/asyncio/futures.py
index 24843c0..13fb47c 100644
--- a/Lib/asyncio/futures.py
+++ b/Lib/asyncio/futures.py
@@ -239,14 +239,15 @@ class Future:
self._schedule_callbacks()
self._log_traceback = True
- def __iter__(self):
+ def __await__(self):
if not self.done():
self._asyncio_future_blocking = True
yield self # This tells Task to wait for completion.
- assert self.done(), "await wasn't used with future"
+ if not self.done():
+ raise RuntimeError("await wasn't used with future")
return self.result() # May raise too.
- __await__ = __iter__ # make compatible with 'await' expression
+ __iter__ = __await__ # make compatible with 'yield from'.
# Needed for testing purposes.