summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2015-11-18 17:39:45 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2015-11-18 17:39:45 (GMT)
commitb3dd6d70c7cde5e2bdb04da388e5a56f2af5ee91 (patch)
tree047d23c5a366fd0e354954542bc0788095c4ff38 /Lib
parent38fe4dc4009394b71ee5cf80f50786c6dadd748d (diff)
downloadcpython-b3dd6d70c7cde5e2bdb04da388e5a56f2af5ee91.zip
cpython-b3dd6d70c7cde5e2bdb04da388e5a56f2af5ee91.tar.gz
cpython-b3dd6d70c7cde5e2bdb04da388e5a56f2af5ee91.tar.bz2
asyncio: Error if awaiting in parallel on the same coroutine
This change won't do anything in CPython 3.4 See https://github.com/python/asyncio/pull/293 for details.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/asyncio/coroutines.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/asyncio/coroutines.py b/Lib/asyncio/coroutines.py
index e11b21b..3a92c7d 100644
--- a/Lib/asyncio/coroutines.py
+++ b/Lib/asyncio/coroutines.py
@@ -140,7 +140,13 @@ class CoroWrapper:
if compat.PY35:
- __await__ = __iter__ # make compatible with 'await' expression
+ def __await__(self):
+ cr_await = getattr(self.gen, 'cr_await', None)
+ if cr_await is not None:
+ raise RuntimeError(
+ "Cannot await on coroutine {!r} while it's "
+ "awaiting for {!r}".format(self.gen, cr_await))
+ return self
@property
def gi_yieldfrom(self):