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
评论列表
文章目录