db.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:aiorethink 作者: lars-tiede 项目源码 文件源码
def _run_query(query, conn = None):
    """`run()`s query if caller hasn't already done so, then awaits and returns
    its result.

    If run() has already been called, then the query (strictly speaking, the
    awaitable) is just awaited. This gives the caller the opportunity to
    customize the run() call.

    If run() has not been called, then the query is run on the given connection
    (or the default connection). This is more convenient for the caller than
    the other version.
    """
    # run() it if caller didn't do that already
    if not inspect.isawaitable(query):
        if not isinstance(query, r.RqlQuery):
            raise TypeError("query is neither awaitable nor a RqlQuery")
        cn = conn or await db_conn
        query = query.run(cn)

    return await query
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号