]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Avoid deprecated asyncio.async() in test 1949/head
authorA. Jesse Jiryu Davis <jesse@mongodb.com>
Thu, 9 Feb 2017 01:23:39 +0000 (20:23 -0500)
committerA. Jesse Jiryu Davis <jesse@mongodb.com>
Thu, 9 Feb 2017 02:48:03 +0000 (21:48 -0500)
tornado/test/asyncio_test.py

index b50b2048ee8e39bb7ae8eebb8f0751336b046d24..6387b11122c4a59b6449529a71fe25f347f8bef9 100644 (file)
@@ -41,8 +41,14 @@ class AsyncIOLoopTest(AsyncTestCase):
     @gen_test
     def test_asyncio_future(self):
         # Test that we can yield an asyncio future from a tornado coroutine.
-        # Without 'yield from', we must wrap coroutines in asyncio.async.
-        x = yield asyncio.async(
+        # Without 'yield from', we must wrap coroutines in ensure_future,
+        # which was introduced during Python 3.4, deprecating the prior "async".
+        if hasattr(asyncio, 'ensure_future'):
+            ensure_future = asyncio.ensure_future
+        else:
+            ensure_future = asyncio.async
+
+        x = yield ensure_future(
             asyncio.get_event_loop().run_in_executor(None, lambda: 42))
         self.assertEqual(x, 42)