Calls to daemon being blocked by executing code
Posted: Sat Jan 18, 2014 5:23 am
I'm not sure if I've got a bug on my hands or if I've misunderstood something basic. Either way I'm in need of help. I'm writing another client script to help me re-organize my media torrents. The problem I've run into is that new calls I make to the daemon from my client script are being blocked.
Here's a simple example script:
As I understand it, since the call is being made asynchronously, the torrent should pause as soon as the daemon receives the call from client.core. However if you run the script above, the torrent won't pause until all other work is done. Nor will just about any call whatsoever execute.
I'm not sure if it's a bug or if there's something basic I'm misunderstanding. It's made my script more or less impossible to build. Can anyone help me out, or at least run the sample script and confirm that it's not just me?
Here's a simple example script:
Code: Select all
from deluge.ui.client import client
from twisted.internet import reactor
import time
class SomeClasss():
def __init__(self):
self.torrents = {}
def onConnect(self, result):
print result
client.core.get_torrents_status(None, ['name']).addCallback(self.populateTorrents)
def populateTorrents(self, data):
self.torrents = data
firstTorrent = self.torrents[self.torrents.keys()[0]]['name']
print firstTorrent, "should pause now!"
client.core.pause_torrent([self.torrents.keys()[0]])
self.doSomethingElse()
def doSomethingElse(self):
time.sleep(20)
# torrent will not pause until control returns to onConnect
print "Done Waiting"
def on_error(self, result):
print 'error connecting', result
def main():
d = client.connect()
MyClass = SomeClasss()
d.addCallback(MyClass.onConnect)
d.addErrback(MyClass.on_error)
reactor.run()
if __name__ == '__main__':
main()
I'm not sure if it's a bug or if there's something basic I'm misunderstanding. It's made my script more or less impossible to build. Can anyone help me out, or at least run the sample script and confirm that it's not just me?