私信  •  关注

Thiago Barros

Thiago Barros 最近创建的主题
Thiago Barros 最近回复了
8 年前
回复了 Thiago Barros 创建的主题 » 使用tornado,为使用sqlalchemy fetchmany()的blocker函数创建异步函数

通常,我用@gen.coroutine decorator将sqlalchemy函数包装在其他方法中,因此它可以是异步方法。

例如。:

@gen.coroutine
def fetchmany():
   return val.cursor.fetchmany(100)

@gen.coroutine
def loop(self):
   I = yield fetchmany()

我希望能帮助你