The import tornado. Ioloop
The import tornado. Web
The import asyncio
LST=[I for I in range (50)]
Async def diaodu_thread () :
For I in LST:
Await walk (I)
Async def walk (arg) :
Print (' -- -- start % s' % arg)
Await asyncio. Sleep (3)
Print (" -- - end % s' % arg)
The class MainHandler (tornado. Web. RequestHandler) :
Def get (self) :
The self. The write (" Hello, world ")
Def make_app () :
Return tornado. Web. Application ([
(MainHandler, r "/"),
])
If __name__=="__main__" :
Asyncio. Run (diaodu_thread ())
App=make_app ()
App. Listen (8888)
Tornado. Ioloop. Ioloop. Current (). The start ()
CodePudding user response:
Diaodu_thread function to modify the
Async def diaodu_thread () :
# for the I in LST:
# await walk (I)
The tasks=[]
For I in LST:
The tasks. Append (asyncio. Create_task (walk) (I))
The tasks await asyncio. Gather (*)
CodePudding user response: