我想使用python库tornado(版本4.2)做一些异步HTTP请求.然而,我可以不强迫未来完成(使用result()),因为我得到一个例外:"DummyFuture不支持阻止结果".
我有python 3.4.3因此未来的支持应该是标准库的一部分.文件concurrent.py说:
龙卷风将
concurrent.futures.Future在可用的情况下使用; 否则它将使用此模块中定义的兼容类.
下面提供了我尝试做的最小示例:
from tornado.httpclient import AsyncHTTPClient;
future = AsyncHTTPClient().fetch("http://google.com")
future.result()
Run Code Online (Sandbox Code Playgroud)
如果我理解我的问题是正确的,因为concurrent.futures.Future不使用某种方式导入.龙卷风中的相关代码似乎已经存在,concurrent.py但我并没有真正在理解问题究竟在哪里取得进展.
在我的数据库模式中有比赛和团队,一个团队有一个first_opponent和一个second_opponent. 现在,这些中的每一个都应该可以作为团队的反向引用。作为第一或第二对手没有真正的区别,因此反向引用应该具有相同的名称。但是,我不能简单地创建两个具有相同名称的反向引用。
这是我的表定义(以简化形式):
class Team(Base):
__tablename__ = "teams"
id = Column(Integer, primary_key=True)
name = Column(String)
class Match(Base):
__tablename__ = "matches"
id = Column(Integer, primary_key=True)
first_opponent_id = Column(Integer, ForeignKey("teams.id"))
second_opponent_id = Column(Integer, ForeignKey("teams.id"))
first_opponent = relationship("Team", backref=backref('matches'), foreign_keys=[first_opponent_id])
second_opponent = relationship("Team", backref=backref('matches'), foreign_keys=[second_opponent_id])
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
sqlalchemy.exc.ArgumentError: Error creating backref 'matches' on relationship 'Match.second_opponent': property of that name exists on mapper 'Mapper|Team|teams'
Run Code Online (Sandbox Code Playgroud)
解决此问题的最佳方法是什么,为什么存在此限制?