mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
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:
parent
dddc781998
commit
0ac3a0cd79
2 changed files with 22 additions and 1 deletions
|
@ -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():
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue