On Thu, Jan 19, 2012 at 6:41 PM, Hanusz L. <han...@aegtranzcom.com> wrote: > > I'd like to create a xmlrpc function get_message with the following > characteristic : > - If the server doesn't have any message to send the client, the server will > answer with a timeout after 60s (and the client can retry) > - If the server has a message to send to the client, the answer is sent > directly > > To do that, can I do the following: > - create a deferred in the xmlrpc function with a calllater of 60s and keep a > reference to this deferred in the factory > * If the server has no message to send, the deferred will be called by the > reactor and answer a timeout > * If the server has a message to send, it will call the deferred in his own > code (with a parameter ?) before the reactor and answer the message.
The object returned by callLater() provides the IDelayedCall[1] interface. If you keep a reference to this object as well as the deferred, then you can cancel the call when you return a response by calling the .cancel() method. [1] http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IDelayedCall.html -- mithrandi, i Ainil en-Balandor, a faer Ambar _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python