asyncio: Make Tasks check if Futures are attached to the same event loop

See https://github.com/python/asyncio/pull/303 for details
This commit is contained in:
Yury Selivanov 2015-12-11 11:33:59 -05:00
parent dddc781998
commit 0ac3a0cd79
2 changed files with 22 additions and 1 deletions

View file

@ -76,6 +76,21 @@ class TaskTests(test_utils.TestCase):
def setUp(self):
self.loop = self.new_test_loop()
def test_other_loop_future(self):
other_loop = asyncio.new_event_loop()
fut = asyncio.Future(loop=other_loop)
@asyncio.coroutine
def run(fut):
yield from fut
try:
with self.assertRaisesRegex(RuntimeError,
r'Task .* got Future .* attached'):
self.loop.run_until_complete(run(fut))
finally:
other_loop.close()
def test_task_class(self):
@asyncio.coroutine
def notmuch():