Closed developer992 closed 20 hours ago
Looks like working as expected - Playwright uses asyncio under the hood, even in our sync implementation.
i am trying to parse a table and process each row individually but i get random order and thus breaks my logic
because i need to rely on sequential order for processing, so i can stop at the right time
something like this:
async def get_objects():
async with self.open_page(url=self.PORTAL_URL) as page:
# do some button clicking, enter form fields, click submit
# which makes ajax call, which i intercept and store objects on self._data
# then i yield these objects one by one
for obj in self._data:
yield obj
my func:
async def func():
async for obj in scrapper.get_objects():
print(f'process obj={obj}')
the processing is in different order than self._data
i tried to switch completely to sync context but then i got the problem above because django didn't want to cooperate on db calls
you may delete this thread
Version
sync_api switches to async context after init
Steps to reproduce
Hello, is this a bug?
It switches to async context for some reason, any idea why?
Expected behavior
i expected it to run in sync context
Actual behavior
it didn't
Additional context
No response
Environment