コード例 #1
0
 async def __aenter__(self) -> AsyncPlaywright:
     self._connection = Connection(None, create_remote_object,
                                   compute_driver_executable())
     loop = asyncio.get_running_loop()
     self._connection._loop = loop
     loop.create_task(self._connection.run())
     playwright = AsyncPlaywright(
         await
         self._connection.wait_for_object_with_known_name("Playwright"))
     playwright.stop = self.__aexit__  # type: ignore
     return playwright
コード例 #2
0
    async def __aenter__(self) -> AsyncPlaywright:
        loop = asyncio.get_running_loop()
        self._connection = Connection(
            None,
            create_remote_object,
            PipeTransport(loop, compute_driver_executable()),
            loop,
        )
        loop.create_task(self._connection.run())
        playwright_future = self._connection.playwright_future

        done, pending = await asyncio.wait(
            {self._connection._transport.on_error_future, playwright_future},
            return_when=asyncio.FIRST_COMPLETED,
        )
        if not playwright_future.done():
            playwright_future.cancel()
        playwright = AsyncPlaywright(next(iter(done)).result())
        playwright.stop = self.__aexit__  # type: ignore
        return playwright
コード例 #3
0
 async def __aenter__(self) -> AsyncPlaywright:
     self._connection = Connection(
         None, create_remote_object, PipeTransport(compute_driver_executable())
     )
     loop = asyncio.get_running_loop()
     self._connection._loop = loop
     obj = asyncio.create_task(
         self._connection.wait_for_object_with_known_name("Playwright")
     )
     await self._connection._transport.start()
     loop.create_task(self._connection.run())
     done, pending = await asyncio.wait(
         {
             obj,
             self._connection._transport.on_error_future,  # type: ignore
         },
         return_when=asyncio.FIRST_COMPLETED,
     )
     if not obj.done():
         obj.cancel()
     obj = next(iter(done)).result()
     playwright = AsyncPlaywright(obj)  # type: ignore
     playwright.stop = self.__aexit__  # type: ignore
     return playwright