mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-44017: Update test_contextlib_async not to emit DeprecationWarn (GH-25918)
This commit is contained in:
parent
985ac01637
commit
698e9a8211
2 changed files with 6 additions and 9 deletions
|
@ -369,16 +369,14 @@ class TestAsyncExitStack(TestBaseExitStack, unittest.TestCase):
|
|||
class SyncAsyncExitStack(AsyncExitStack):
|
||||
@staticmethod
|
||||
def run_coroutine(coro):
|
||||
loop = asyncio.get_event_loop()
|
||||
|
||||
f = asyncio.ensure_future(coro)
|
||||
f.add_done_callback(lambda f: loop.stop())
|
||||
loop = asyncio.get_event_loop_policy().get_event_loop()
|
||||
t = loop.create_task(coro)
|
||||
t.add_done_callback(lambda f: loop.stop())
|
||||
loop.run_forever()
|
||||
|
||||
exc = f.exception()
|
||||
|
||||
exc = t.exception()
|
||||
if not exc:
|
||||
return f.result()
|
||||
return t.result()
|
||||
else:
|
||||
context = exc.__context__
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue