The problem of execution sequence of python collaboration programs

problem description:

when I was working on the actual combat article of Liao Xuefeng, I had a question when operating the database. I first defined two co-programs, and then defined a main co-program await to execute the two co-programs sequentially. (I think.), was executed sequentially and the log was printed, and it was found that it was not the result I expected.

python version: 3.6.4

the complete code is as follows:

   
(Note: actually the order is not certain, sometimes 1 is in the first column)

my doubts:

await is not yield from ? That is, give control to the main loop, so shouldn"t I have more than one await in the same loop to execute sequentially? So according to reason, shouldn"t 1 be displayed in the first column?

Mar.16,2021

tested more than 30 times on the command line to avoid out-of-order problems, and determined that it was the pycharm itself.

Menu