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)

  

上一篇:aiohttp使用方法


下一篇:树链剖分模板-2716-【ZJOI2008】树的统计