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(