asyncio和aiohttp携程并发
import asyncio
from aiohttp import web
import time
async def process():
for i in range(10):
print("process data !!")
# time.sleep(1)
await asyncio.sleep(1)
async def hello(request):
job = process()
asyncio.create_task(job)
return web.Response(text='Hello Aiohttp!')
app = web.Application()
app.router.add_get("/hello",hello)
web.run_app(app, host="0.0.0.0", port=9000)
多思考也是一种努力,做出正确的分析和选择,因为我们的时间和精力都有限,所以把时间花在更有价值的地方。

浙公网安备 33010602011771号