Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winloop + Playwright -> startupinfo is not supported #34

Open
Haydart opened this issue Sep 22, 2024 · 3 comments
Open

Winloop + Playwright -> startupinfo is not supported #34

Haydart opened this issue Sep 22, 2024 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Haydart
Copy link

Haydart commented Sep 22, 2024

Hi, first of all thank you for doing this project, it's been massively helpful when running my project on Windows.
My project used to use Selenium 4.12 for automating browser actions, recently I switched up to Playwright.
However, suddenly on Windows I started getting problems. I'm unable to spin up Playwright doe to this crash when Playwright tries to run login in a subprocess:

future: <Task finished name='Task-18' coro=<Connection.run() done, defined at C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\_impl\_connection.py:265> exception=ValueError('startupinfo is not supported')>
Traceback (most recent call last):
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\_impl\_connection.py", line 272, in run
    await self._transport.connect()
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\_impl\_transport.py", line 133, in connect
    raise exc
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\_impl\_transport.py", line 120, in connect
    self._proc = await asyncio.create_subprocess_exec(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\asyncio\subprocess.py", line 223, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "winloop\loop.pyx", line 2832, in subprocess_exec
  File "winloop\loop.pyx", line 2773, in __subprocess_run
ValueError: startupinfo is not supported
Traceback (most recent call last):
  File "C:\Users\[REDACTED]\src\tasks\base_task.py", line 125, in execute
    self.browser_context, self.profile = await provide_browser(self.account_id)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\src\ops\open_browser_session.py", line 118, in open_browser_for_profile
    browser_context = await browser_coro
                      ^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\src\ops\open_browser_session.py", line 98, in get_browser
    playwright = self.__playwright = (await async_playwright().start())
                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\async_api\_context_manager.py", line 51, in start
    return await self.__aenter__()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\async_api\_context_manager.py", line 46, in __aenter__
    playwright = AsyncPlaywright(next(iter(done)).result())
                                 ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\playwright\_impl\_transport.py", line 120, in connect
    self._proc = await asyncio.create_subprocess_exec(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\asyncio\subprocess.py", line 223, in create_subprocess_exec
    transport, protocol = await loop.subprocess_exec(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "winloop\loop.pyx", line 2832, in subprocess_exec
  File "winloop\loop.pyx", line 2773, in __subprocess_run
ValueError: startupinfo is not supported
Process SpawnProcess-1:
Traceback (most recent call last):
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
Traceback (most recent call last):
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "winloop\loop.pyx", line 1520, in winloop.loop.Loop.run_until_complete
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 314, in _bootstrap
    self.run()
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\concurrent\futures\process.py", line 249, in _process_worker
    call_item = call_queue.get(block=True)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\queues.py", line 103, in get
    res = self._recv_bytes()
          ^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\connection.py", line 216, in recv_bytes
    buf = self._recv_bytes(maxlength)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\multiprocessing\connection.py", line 321, in _recv_bytes
    waitres = _winapi.WaitForMultipleObjects(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
KeyboardInterrupt
  File "C:\Users\[REDACTED]\venv\Lib\site-packages\winloop\__init__.py", line 63, in wrapper
    return await main
           ^^^^^^^^^^
  File "C:\Users\[REDACTED]\src\main.py", line 31, in main
    await aio.sleep(1)
  File "C:\Users\[REDACTED]\AppData\Local\Programs\Python\Python311\Lib\asyncio\tasks.py", line 649, in sleep
    return await future
           ^^^^^^^^^^^^
asyncio.exceptions.CancelledError

This is how I currently run my main logic loop:

async def main():
    # async operations
    while True:
        await aio.sleep(1)


if __name__ == "__main__":
    if sys.platform in ('win32', 'cygwin', 'cli'):
        import winloop 
        aio.set_event_loop_policy(winloop.EventLoopPolicy())
        winloop.run(main())
    else:
        from uvloop import run
        run(main())

Is there any way this error can be circumvented / fixed / monkey-patched? I would really like to continue using winloop for this project, the speed of execution improvements are uncanny.

@Vizonex
Copy link
Owner

Vizonex commented Sep 22, 2024

@Haydart When it comes to launching a process one of the things I tried to do was that winloop would release the GIL during the initial launch of the process, this was done due to the fact that windows doesn't fork processes and I clearly wanted something that would be it's equal to replace it, perhaps maybe I can look into getting rid of releasing the GIL upon launching the process up first thing and see if it does anything. Otherwise if it isn't our fault after I've made those fixes I would raise this concern to the authors of playwright. I may not be able to fix it right away however due to me being busy with work. But in the meantime Let me give this some careful thinking and consideration. However I also believe that this could be winapi's fault and not my own code that I've written over a year ago. Again glad you brought this issue up for me and the rest of us.

@Vizonex Vizonex added bug Something isn't working help wanted Extra attention is needed labels Sep 22, 2024
@Vizonex
Copy link
Owner

Vizonex commented Sep 22, 2024

@Haydart I'll also see if me or someone else would be willing to write a unittest for playwright specifically to see if that does anything so that this webdriver is supported more in the future.

@Vizonex Vizonex pinned this issue Sep 22, 2024
@Vizonex
Copy link
Owner

Vizonex commented Sep 25, 2024

@Haydart I added playwright as part of the testsuite now so hopefully me or one of the other contributors will be able to work on what's causing your problems now.

@lschoe lschoe unpinned this issue Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants