I've started learning playwright-python and the package playwright
has the two submodules async_api
and sync_api
. However I could not find any deeper description or discussion on their respective benefits and drawbacks. From their names I assume that the synchronous API calls are blocking and the asynchronous ones run in the background?
Are they different in their capabilities, i.e. are there scenarios in which the sync_api
cannot accomplish something you can do using the async_api
(or vice versa)?
The sync_api
is simply a wrapper around the async_api
that abstracts asyncio usage away from you. As such, the capabilities are largely the same, but the async_api
may afford some more flexibility in complex scenarios.
I would suggest using async in case you need the flexibility in the future, or sync for ease of use.