[英]Autobahn Python 0.9.3-3 raises exception related to “subscription_revocation”
[英]Autobahn | Python: Subscription no longer triggering handler when SubscriptionOptions are provided
我目前正在用Python构建一个加密货币交易平台,并使用高速公路来接收市场事件。 我在使用订阅选项时遇到问题。
当我仅使用(处理程序,主题)参数创建预订,并使处理程序采用单个参数时,一切正常。 但是,当我使用(处理程序,主题,选项)参数创建预订,并使处理程序带有两个参数时,不会调用处理程序。 在文档中,它指出在这种情况下,处理程序应具有三个参数args,kwargs和details。 当我使处理程序接受三个参数时,它也不起作用。 我无奈地尝试了0到5个参数之间的所有内容。
简而言之,当我不使用任何订阅选项并为处理程序提供一个参数时,它可以正常工作。 使用订阅选项时, 无论使用多少参数 ,都不会触发处理程序。
我尝试打印出该对,并且它是有效的字符串,并且尝试打印出这些选项,并且它是有效的subscriptionsoptions对象。 注意,我将“ none”用作匹配条件。 我仍然收到订阅确认,没有错误。
任何建议将不胜感激。
代码如下。
def onJoin(self, details):
print("{} client session ready".format(self.exchange))
def marketEvent(args, kwargs, details):
print("marketEvent called")
# Read in configuration files
try:
pairs = [line.strip() for line in open("conf/" + self.exchange + ".conf")]
except:
print("Configuration file not found for {}!".format(self.exchange))
sys.exit(1)
# Subscribe to each currency pair / topic in the conf file
for pair in pairs:
try:
# provide currency pair name to handler
options = SubscribeOptions(details_arg = pair)
yield from self.subscribe(marketEvent, pair, options)
print("subscribed to {} on {}".format(pair, self.exchange))
except Exception as e:
print("could not subscribe to {} on {}: {}".format(pair, exchange, e))
sys.exit(1)
已修复,在我的一个朋友的帮助下。 marketEvent所需的签名如下:
marketEvent(事件,**详细信息)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.