我正在使用“旋风”和“Postgres”,我有一些查询(4或5),我在程序期间附加到列表中,现在我想一次执行所有这些查询!
当我试图执行时,我得到的错误是:
"DummyFuture does not support blocking for results" 我执行了以下代码:
yield self.db.execute(''.join(queries)).result() “查询”是查询列表!
这是我的连接池和Tonado设置:
ioloop = IOLoop.instance()
application.db = momoko.Pool(
dsn='dbname=xxx user=xxx password=xxxx host=x port=xxxx'
size=xx,
ioloop=ioloop,
)
# this is a one way to run ioloop in sync
future = application.db.connect()
ioloop.add_future(future, lambda f: ioloop.stop())
ioloop.start()
future.result() # raises exception on connection error
http_server = HTTPServer(application)
http_server.listen(8888, 'localhost')
ioloop.start()发布于 2016-10-05 12:51:17
不要在龙卷风中召唤未来的result()。得到这样的结果:
@gen.coroutine
def method(self):
result = yield self.db.execute('...')而且,我认为将查询作为字符串加入是行不通的。结果将不是有效的SQL。相反:
@gen.coroutine
def method(self):
results = yield [self.db.execute(q) for q in queries]https://stackoverflow.com/questions/39872583
复制相似问题