diff options
author | Yury Selivanov <yselivanov@sprymix.com> | 2015-11-18 17:40:26 (GMT) |
---|---|---|
committer | Yury Selivanov <yselivanov@sprymix.com> | 2015-11-18 17:40:26 (GMT) |
commit | 576fe71c12502349aab70f0b2b0c84ca72b47165 (patch) | |
tree | ddc84fa1098168edd6471b70382dfd394a997728 /Lib/test/test_asyncio | |
parent | 1535311edcc8d5cdc4a4615abeb6d5ea6a606c5e (diff) | |
parent | b3dd6d70c7cde5e2bdb04da388e5a56f2af5ee91 (diff) | |
download | cpython-576fe71c12502349aab70f0b2b0c84ca72b47165.zip cpython-576fe71c12502349aab70f0b2b0c84ca72b47165.tar.gz cpython-576fe71c12502349aab70f0b2b0c84ca72b47165.tar.bz2 |
asyncio: Error if awaiting in parallel on the same coroutine
See https://github.com/python/asyncio/pull/293 for details.
Diffstat (limited to 'Lib/test/test_asyncio')
-rw-r--r-- | Lib/test/test_asyncio/test_pep492.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_pep492.py b/Lib/test/test_asyncio/test_pep492.py index 41e1b8a..404a748 100644 --- a/Lib/test/test_asyncio/test_pep492.py +++ b/Lib/test/test_asyncio/test_pep492.py @@ -203,6 +203,26 @@ class CoroutineTests(BaseTest): self.loop.run_until_complete(runner()) + def test_double_await(self): + async def afunc(): + await asyncio.sleep(0.1, loop=self.loop) + + async def runner(): + coro = afunc() + t = asyncio.Task(coro, loop=self.loop) + try: + await asyncio.sleep(0, loop=self.loop) + await coro + finally: + t.cancel() + + self.loop.set_debug(True) + with self.assertRaisesRegex( + RuntimeError, + r'Cannot await.*test_double_await.*\bafunc\b.*while.*\bsleep\b'): + + self.loop.run_until_complete(runner()) + if __name__ == '__main__': unittest.main() |