Skip to content

Commit

Permalink
use asyncio.run to run coroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Dec 15, 2023
1 parent f075c8b commit 895ae20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/integration/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@


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):
Expand Down

0 comments on commit 895ae20

Please sign in to comment.