Async
Last updated
Last updated
Is a concurrent programming pattern.
The SO manages all the multi-tasking work.
In CPython, the GIL (Global Interpreter Lock) stops concurrency by using multiple cores - the interpreter is locked to one core.
Without SO intervention.
One process, one thread.
Async functions need the power to suppress and resume.
The power to suppress a function for a time period when it should be suspended and only resume it when the wait has ended.
Implementing suppression/resume in Python requires:
Callback's.
Generators.
Async/Await (Python 3.5+).
Async frameworks need a scheduler, usually called an "event loop".
The loop takes care of all tasks in execution.
When a function is suppressed, it returns power to the loop which is looking for another function that succeeds it.
All of this is called "cooperative multi-tasking".