Notes on python async implementation

2022 July 5
  • Comparing with Javascript: Javascript works with “callbacks” (pipelines). It runs a function and it passes control to another one. There are success callbacks, error callbacks, etc.

  • Python’s async uses coroutines - which is different than working with callbacks. You have preemptive multiprocessing - cooperative task switching. There are no callbacks. You “mark” async code with “await” and “yield” - you explicitly tell where to stop or give opportunity for another thing to be run. There are some libraries to emulate Javascript callback behavior, but do that on your own risk.