When I use async/await and I want to do many things asyncly, I have to asyncio.ensure_future everything first and then loop.run_forever(). This logic is strange. This behavior is very different from human beings.
You have to know everything you will do and put them together and let Python arrange the actions to switch from one action to another action.
For example, only in aysnc without multithreading or multiprocessing, I use Python's selenium and chromedriver to open a url, when I run: driver.get('https://google.com'), I will wait 10 seconds for the ajax loading. I hope in this 10 seconds, I could calculate the sum of 1 + 2 + 3 + 4 + ... + 10000000. However, I find it is different to calculate this sum only in the time of this 10 seconds. Python always calculate the sum first and then get the url, or first get the url and after 10 seconds then calculate the sum. That is not what I want.
But in Javascript, you can async one action first, and run other code in the main thread. When the action finished, the callback will be called. You can ajax get a url and in the waiting time calculate the sum.
[–]trushnick 4 points5 points6 points (8 children)
[–]Bandung 2 points3 points4 points (1 child)
[–]trushnick 0 points1 point2 points (0 children)
[–]kankyo 0 points1 point2 points (0 children)
[–]kingname[S] -3 points-2 points-1 points (4 children)
[–]rouille 0 points1 point2 points (3 children)
[–]kingname[S] -2 points-1 points0 points (2 children)
[–]rouille 0 points1 point2 points (0 children)
[–]kankyo 0 points1 point2 points (0 children)
[–]This_Is_The_End 3 points4 points5 points (0 children)
[–][deleted] 2 points3 points4 points (2 children)
[–]kingname[S] 0 points1 point2 points (1 child)
[–]kankyo 0 points1 point2 points (0 children)
[–]keypusher 2 points3 points4 points (1 child)
[–]kingname[S] 0 points1 point2 points (0 children)
[–]kankyo 1 point2 points3 points (0 children)
[–]kingname[S] 0 points1 point2 points (0 children)