[Twisted-Python] help using deferred
exarkun at divmod.com
Mon May 11 14:01:21 EDT 2009
On Mon, 11 May 2009 19:49:19 +0200, Luigi Conte <luigiandcosolutions at gmail.com> wrote:
>in my script I have to use connect method and then I have to do some
>operations first of calling the start method
>1) start connection
> def startConnection(self):
> d = my_api.connect(self.ctrl_ip, self.ctrl_port, self.user,
Since you omitted the definition of postConnection, I have no way to know
what this does.
Regardless, this is the wrong place to insert this errback. You should read
the Deferred documentation to learn what consequence it will have on your
probably a good place to start.
> print "Connection added"
> return d
>2) operation before starting a virtual machine:
>def newVMCfg(self, new_vms_cfg):
> #some operations
> #if condition valid I try to start the virtual machine
> # is this the correct way to pass args to the start
> d = self.d.addCallback(self.startVM,(new_vm,
> print "started vm %s"%new_vm
> return d
>in the main process I call them as:
>d = startConnection()
>Is it correct? Because the process stops at the first method called: I see
>only "connection added".
That should indicate to you that something is going wrong after that print
statement is reached. So examine what your program tries to do after that
point. You may want to use a debugger. You may want to try writing some
More information about the Twisted-Python