6

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)?

buddemat
  • 4,552
  • 14
  • 29
  • 49

1 Answers1

8

The sync_api is simply a wrapper around the asyncio_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.

Mattwmaster58
  • 2,266
  • 3
  • 23
  • 36