老師,幫忙看一下,為什么用并發(fā)的方式與同步方式的時(shí)間是一樣的,不知道哪兒出錯(cuò)了
import?tornado.ioloop from?tornado.httpclient?import?AsyncHTTPClient N?=?3 URL?=?"http://127.0.0.1:8888/sleep" async?def?main(): ????http_client?=?AsyncHTTPClient() ????responses?=?[await?http_client.fetch(URL)?for?i?in?range(N)] start_time?=?time.time() tornado.ioloop.IOLoop.current().run_sync(main) print("async",?time.time()?-?start_time) beg?=?time.time() for?i?in?range(N): ????requests.get(URL) print(time.time()?-?beg)
2019-11-25
(1)還需要async_server.py
(2)沒有import time, requests, gen
(3)沒有用裝飾器@gen.coroutine修飾main()
2019-04-19
你服務(wù)端的代碼不放出來怎么看呀