Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

并不是异步执行的? #1

Open
zhaoxuyan opened this issue Jul 2, 2021 · 0 comments
Open

并不是异步执行的? #1

zhaoxuyan opened this issue Jul 2, 2021 · 0 comments

Comments

@zhaoxuyan
Copy link

zhaoxuyan commented Jul 2, 2021

from sanic import Sanic
from sanic import json
from sanic import response
from sanicdb import SanicDB

app = Sanic('demo')
db = SanicDB('0.0.0.0', 'xxx', 'xuyanzhao', 'xxxxx', sanic=app)


@app.route('/')
async def index(request):
    sql = "select sum(ProcessTime), sum(FileTime) from data_20210702 where(InsertDate <= '2021-07-02 15:59:52')"
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    data = await app.db.query(sql)
    print(data)
    

    return json({"code": 200})


if __name__ == '__main__':
    app.run(host="0.0.0.0", port=8600)

这段代码是一条一条顺序执行的。最后查询的时间等于所有query查询之和。并不是异步的。请问是什么原因呢?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant