[Twisted-Python] how to delay the response in the protocol.Protocol

In the protocol derived class and dataReceived function, I need to send response with given delay using self.transport.write(str(msg)). I guess I would use "maybeDeferred" class to do that. How to pass the delay value. Please advice, A.

On Thu, Aug 11, 2005 at 10:16:14AM -0700, Andrzej Leszczynski wrote:
In the protocol derived class and dataReceived function, I need to send response with given delay using self.transport.write(str(msg)).
how about reactor.callLater(delay, self.transport.write, str(msg))? -w

--- William Waites <ww@groovy.net> wrote:
On Thu, Aug 11, 2005 at 10:16:14AM -0700, Andrzej Leszczynski wrote:
In the protocol derived class and dataReceived function, I need to send response with given delay using self.transport.write(str(msg)).
how about reactor.callLater(delay, self.transport.write, str(msg))?
Will try that but this assumes that you know msg at point of handling the dataReceived. The hidden part of my question is that I would like to deffer/delay processing the dataReceived in general becasue of a few design reasons. This is why I asked about that Deffered. I learn Twisted, so sorry for simple question. Want to have most Pythonic/Twisthonic solution. Thx, A.

On Thu, Aug 11, 2005 at 10:36:35AM -0700, Andrzej Leszczynski wrote:
Will try that but this assumes that you know msg at point of handling the dataReceived. The hidden part of my question is that I would like to deffer/delay processing the dataReceived in general becasue of a few design reasons. This is why I asked about that Deffered.
Well, then you'd do the same sort of thing: reactor.callLater(delay, self.processDataAndSend, data)
I learn Twisted, so sorry for simple question. Want to have most Pythonic/Twisthonic solution.
No need to apologize. Deferreds are not what you are after, they represent data that will be available at some undefined but hopefully bounded time in the future. They're note used for scheduling in the sense that you are talking about. Cheers, -w

On Aug 11, 2005, at 7:16 AM, Andrzej Leszczynski wrote:
In the protocol derived class and dataReceived function, I need to send response with given delay using self.transport.write(str(msg)).
I guess I would use "maybeDeferred" class to do that. How to pass the delay value.
No, you'd use callLater(delay, self.transport.write, str(msg)) -bob
participants (3)
-
Andrzej Leszczynski
-
Bob Ippolito
-
William Waites