[Twisted-Python] help using deferred

Jean-Paul Calderone exarkun at divmod.com
Mon May 11 11:29:43 EDT 2009


On Mon, 11 May 2009 16:55:40 +0200, Luigi Conte <luigiandcosolutions at gmail.com> wrote:
>I'm sure you're saying only good things but I'm so inexpert in twisted that
>I can't understand very well what to do.
>I'll try to explain all that I want to do and how I did it wrongly:
>first I have to call the connect method from the api and it returns a
>deferred so I do:
>in conn_to_ctrl i have:
>d = api.connect(...)
>return d
>
>now I do some operations with config files to call many times the start
>method from the api (I have to start many virtual machines) and the
>api.start returns a deferred so what have I to do now?
>I do so:
>in examinecfg i have:
># tha same d that i used to add api.connect!
>self.d.addCallback(api.start, (method_args))
>return d
>
>Then I have to call the disconnect method from the api. But i tried to print
>out something to fallow the executing but I only see printing the first
>method that call the connection. after that the process ends.
>
>In the main I have:
>defer = conn_to_ctrl()
>or have I to add to defer also the examinecfg?
>
>thank you very much

I'm not sure what you're doing wrong.  It's hard to understand mixed up
snippets and fragments of code.  Please:

  - don't top post
  - share complete, runnable examples (preferably minimal, too)
  - share the failure you're seeing - possibly including a traceback, or a
    description of the behavior that the program exhibits when you run it,
    and an explanation of how this differs from what you want

Jean-Paul




More information about the Twisted-Python mailing list