[Twisted-Python] Chaining deferreds - Twisted+PyGtk
Jean-Paul Calderone
exarkun at divmod.com
Wed Jul 15 19:14:46 MDT 2009
On Thu, 16 Jul 2009 00:36:33 +0200, Ćukasz Rekucki <lrekucki at gmail.com> wrote:
>Hello,
>
>I'm writing a simple chat client using twisted and pygtk. I have a problem
>with a chained deferred not being continued. Here is my call chain:
>
>* MyProtocol.dataReceived -> fires a predefined Deferred [call it A]
>* A.callback1 -> creates a new Deferred B, adds a single callback to it,
>displays a GtkDialog returns B
>* [A stops]
>* dialog exits, I call B.callback(result_id) from the signal callback
>* all callback in B's chains are called
>* program hangs instead calling A.callback2
>
>Is this a thread related problem ? Am I doing something terribly wrong by
>calling a deferred from the gtk thread ?
It sounds like you're doing the right thing. There is no gtk thread when you
use one of the gtk integration reactors - gtk and Twisted coexist in the same
thread. So it's just fine to use Twisted APIs from a gtk signal callback.
Perhaps there is an unexpected error occurring. Do you have a final errback
on your Deferred (one on A in this case would be fine) which logs the error
or otherwise makes it visible? If not, you have to rely on luck and the
garbage collector to make this report.
Jean-Paul
More information about the Twisted-Python
mailing list