我在使用扭曲的框架时遇到问题,我无法重新启动。我的代码需要连接到某些不同节点中的不同洪水客户端守护进程。为此,我需要先断开连接,但扭曲不允许我重新连接到另一个客户端。这是我的代码:
ip = ['localhost', 'debci-lab']
for i in range(len(ip)):
ip_connect = ip[i]
d = client.connect(host=ip_connect)
# We create a callback function to be called upon a successful connection
def on_get_config(result):
print result
def on_connect_success(result):
print "Connection was successful!"
print "result:", result
client.core.get_torrent_status('dd69058c737d914c4e8e985d47a29606de80d34e', ['download_payload_rate']).addCallback(on_get_config)
client.disconnect()
# We add the callback to the Deferred object we got from connect()
d.addCallback(on_connect_success)
# We create another callback function to be called when an error is encountered
def on_connect_fail(result):
print "result:", result
# We add the callback (in this case it's an errback, for error)
d.addErrback(on_connect_fail)
reactor.run()
循环只工作一次,并输出:连接成功!结果:10
但不是预期的下载速率。
感谢您的时间。
此致。