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

Playwright sync API isn't compatible with PySimpleGUI event loop #1

Closed
elkd opened this issue Mar 15, 2022 · 1 comment
Closed

Playwright sync API isn't compatible with PySimpleGUI event loop #1

elkd opened this issue Mar 15, 2022 · 1 comment

Comments

@elkd
Copy link
Owner

elkd commented Mar 15, 2022

When running pw sync code inside sg loop, pw complains that the blocking code was never awaited and runtime exception is thrown

Traceback (most recent call last): File "/home/el/workspace/contract/deriv/trade.py", line 59, in <module> trade_session.login(values['_EMAIL_'], values['_PWORD_']) File "/home/el/workspace/contract/deriv/session.py", line 23, in login self.page.goto("https://smarttrader.deriv.com/") File "/home/el/workspace/.venv/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 7328, in goto self._sync( File "/home/el/workspace/.venv/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 100, in _sync task = self._loop.create_task(coro) File "/usr/lib/python3.10/asyncio/base_events.py", line 431, in create_task self._check_closed() File "/usr/lib/python3.10/asyncio/base_events.py", line 510, in _check_closed raise RuntimeError('Event loop is closed') RuntimeError: Event loop is closed sys:1: RuntimeWarning: coroutine 'Page.goto' was never awaited

Seems related to this pw issue 178

@elkd
Copy link
Owner Author

elkd commented Mar 15, 2022

Could be because PW internally relies on asynchronous operations eg when using time.sleep(5) they can't get processed correctly. So the quick fix can be turning the whole codebase inside sp event loop to be async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant