1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

use asyncio.run to run coroutines

This commit is contained in:
Thomas Grainger
2023-12-15 11:39:51 +00:00
parent f075c8b0b4
commit 895ae205ca

View File

@@ -14,10 +14,10 @@ from .aiohttp_utils import aiohttp_app, aiohttp_request # noqa: E402
def run_in_loop(fn):
with contextlib.closing(asyncio.new_event_loop()) as loop:
asyncio.set_event_loop(loop)
task = loop.create_task(fn(loop))
return loop.run_until_complete(task)
async def wrapper():
return await fn(asyncio.get_running_loop())
return asyncio.run(wrapper())
def request(method, url, output="text", **kwargs):