def execute(self):
loop = self.database.loop
with contextlib.ExitStack() as exit_stack:
exit_stack.enter_context(patch(self, '_execute', _QueryExecutor(self._execute, loop=loop)))
exit_stack.enter_context(patch(peewee, 'map', functools.partial(_map, loop=loop), map))
exit_stack.enter_context(patch(peewee, 'zip', functools.partial(_zip, loop=loop), zip))
result = super().execute()
if inspect.isawaitable(result):
return await result
elif isinstance(result, list):
return await asyncio.gather(*result, loop=loop)
return result
评论列表
文章目录