druge / Twisted脚本在reactor.run()之后挂起

时间:2015-01-27 17:56:09

标签: python twisted rpc reactor twisted.internet

这是来自dev.deluge-torrent.org的简单示例脚本,用于与Deluge API进行交互。

在reactor.run()之后没有任何事情发生,我没有得到"连接成功"消息,它只会永远挂起。

我在我的Ubuntu机器上运行它可以正常工作,但是我无法在我的Windows机器上运行它我真的想要使用它。

from deluge.ui.client import client
# Import the reactor module from Twisted - this is for our mainloop
from twisted.internet import reactor

# Set up the logger to print out errors
from deluge.log import setupLogger
setupLogger()

# Connect to a daemon running on the localhost
# We get a Deferred object from this method and we use this to know if and when
# the connection succeeded or failed.
d = client.connect()

# We create a callback function to be called upon a successful connection
def on_connect_success(result):
    print "Connection was successful!"
    print "result:", result
    # Disconnect from the daemon once we successfully connect
    client.disconnect()
    # Stop the twisted main loop and exit
    reactor.stop()

# 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 "Connection failed!"
    print "result:", result

# We add the callback (in this case it's an errback, for error)
d.addErrback(on_connect_fail)

# Run the twisted main loop to make everything go
reactor.run()

我不知道如何调试此问题。我对Twisted很新,据我所知,它是一个庞大的图书馆。

0 个答案:

没有答案