-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Appendix: Yet Another Introduction to Asyncio #84
Comments
In my opinion the following greatly simplifies explaining Asyncio. Explanation: There are a bunch of fancy terms in asynchronous programming but they can all essentially be explained as 'context' and 'context switching'. A thread, a task, a process are all essentially the same thing, they are differently sized 'contexts environments'. Multithreading or multiprocessing is essentially context switching(sometimes between cpus). Asyncio in python is context switching for a very small 'context environment'. Tasks are slightly larger 'context environment', threads are larger than task, and process is larger than thread(and introduces cpu's). You cant have alot of threads and processes because of the context environment overhead taking up a bunch of memory, but you can have many async awaits because there is little to no overhead. I could be wrong but its the best way to understand it quickly in my opinion. |
Thank for your suggestions. Recently, many languages introduce async/await into their syntax such as javascript. However, the hardest for me was that Python mixed generator and async/await together because Python used generator to implement a user space scheduler. That is why I created this issue for explaining how this scheduler work. |
I'm not familar with Python's use of a generator to implement a user space scheduler, but I am familiar with Pythons scheduler and have experimented with pythons async generators. Async generators are the most confusing thing in python imo. Maybe I can break it down with my context and context switching idea(ive yet to try breaking it down because my realization about asyncio essentially being context saving and context switching has only come in the last year). |
missing explanation.
The text was updated successfully, but these errors were encountered: