Skip to content

Commit b3dd6d7

Browse files
committed
asyncio: Error if awaiting in parallel on the same coroutine
This change won't do anything in CPython 3.4 See python/asyncio#293 for details.
1 parent 38fe4dc commit b3dd6d7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Lib/asyncio/coroutines.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,13 @@ def gi_code(self):
140140

141141
if compat.PY35:
142142

143-
__await__ = __iter__ # make compatible with 'await' expression
143+
def __await__(self):
144+
cr_await = getattr(self.gen, 'cr_await', None)
145+
if cr_await is not None:
146+
raise RuntimeError(
147+
"Cannot await on coroutine {!r} while it's "
148+
"awaiting for {!r}".format(self.gen, cr_await))
149+
return self
144150

145151
@property
146152
def gi_yieldfrom(self):

0 commit comments

Comments
 (0)