From 608bbb2e06e58d048e03826164074dc83f7a9432 Mon Sep 17 00:00:00 2001 From: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Date: Mon, 7 Jun 2021 21:40:03 +0530 Subject: [PATCH] chore: use `asyncio.get_running_loop` instead of `asyncio.get_event_loop` (#742) --- playwright/_impl/_sync_base.py | 2 +- playwright/async_api/_context_manager.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/playwright/_impl/_sync_base.py b/playwright/_impl/_sync_base.py index a24e95b14..3b8e99af6 100644 --- a/playwright/_impl/_sync_base.py +++ b/playwright/_impl/_sync_base.py @@ -81,7 +81,7 @@ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> None: class SyncBase(ImplWrapper): def __init__(self, impl_obj: Any) -> None: super().__init__(impl_obj) - self._loop: asyncio.BaseEventLoop = impl_obj._loop + self._loop: asyncio.AbstractEventLoop = impl_obj._loop self._dispatcher_fiber = impl_obj._dispatcher_fiber def __str__(self) -> str: diff --git a/playwright/async_api/_context_manager.py b/playwright/async_api/_context_manager.py index 7e9cae8db..1f60509b5 100644 --- a/playwright/async_api/_context_manager.py +++ b/playwright/async_api/_context_manager.py @@ -27,15 +27,15 @@ def __init__(self) -> None: self._connection: Connection async def __aenter__(self) -> AsyncPlaywright: + loop = asyncio.get_running_loop() self._connection = Connection( None, create_remote_object, - PipeTransport(asyncio.get_event_loop(), compute_driver_executable()), + PipeTransport(loop, compute_driver_executable()), ) - loop = asyncio.get_running_loop() self._connection._loop = loop loop.create_task(self._connection.run()) - playwright_future = asyncio.create_task( + playwright_future = loop.create_task( self._connection.wait_for_object_with_known_name("Playwright") ) done, pending = await asyncio.wait(