[Twisted-Python] Flow control

For a test driver for a TCP-based protocol (written in Twisted) I want to send data to a receiver as fast as the receiver can consume data, but not faster. Apparently, a naive loop which just does transport.write() does not work. When I do reactor.select(0) between the writes, it somehow works, but memory consumption of sender is growing fast, since I guess data is buffered within Twisted, right? I then got over implementing my own application level flow control, where the receiver gives feedback of how much it has consumed, and the sender throttles itself to that. However, isn't there a simpler way (without application level flow control)? In the end, the sender TCP stack must have knowledge of it's window size .. is there a way to get at that info? What is the recommended way?

On Thu, Aug 11, 2011 at 5:13 PM, Tobias Oberstein < tobias.oberstein@tavendo.de> wrote:
You want to write a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html -- Christopher Armstrong http://radix.twistedmatrix.com/ http://planet-if.com/

ahh, I felt I missed sth;) thx .. I'll look into that On 11.08.11 23:16, "Christopher Armstrong" <radix@twistedmatrix.com> wrote: On Thu, Aug 11, 2011 at 5:13 PM, Tobias Oberstein <tobias.oberstein@tavendo.de> wrote: For a test driver for a TCP-based protocol (written in Twisted) I want to send data to a receiver as fast as the receiver can consume data, but not faster. Apparently, a naive loop which just does transport.write() does not work. When I do reactor.select(0) between the writes, it somehow works, but memory consumption of sender is growing fast, since I guess data is buffered within Twisted, right? I then got over implementing my own application level flow control, where the receiver gives feedback of how much it has consumed, and the sender throttles itself to that. However, isn't there a simpler way (without application level flow control)? In the end, the sender TCP stack must have knowledge of it's window size .. is there a way to get at that info? What is the recommended way? You want to write a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html

Transports provide the IConsumer interface, to which you can hook up a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html

On Thu, Aug 11, 2011 at 5:13 PM, Tobias Oberstein < tobias.oberstein@tavendo.de> wrote:
You want to write a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html -- Christopher Armstrong http://radix.twistedmatrix.com/ http://planet-if.com/

ahh, I felt I missed sth;) thx .. I'll look into that On 11.08.11 23:16, "Christopher Armstrong" <radix@twistedmatrix.com> wrote: On Thu, Aug 11, 2011 at 5:13 PM, Tobias Oberstein <tobias.oberstein@tavendo.de> wrote: For a test driver for a TCP-based protocol (written in Twisted) I want to send data to a receiver as fast as the receiver can consume data, but not faster. Apparently, a naive loop which just does transport.write() does not work. When I do reactor.select(0) between the writes, it somehow works, but memory consumption of sender is growing fast, since I guess data is buffered within Twisted, right? I then got over implementing my own application level flow control, where the receiver gives feedback of how much it has consumed, and the sender throttles itself to that. However, isn't there a simpler way (without application level flow control)? In the end, the sender TCP stack must have knowledge of it's window size .. is there a way to get at that info? What is the recommended way? You want to write a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html

Transports provide the IConsumer interface, to which you can hook up a producer: http://twistedmatrix.com/documents/current/core/howto/producers.html
participants (3)
-
Christopher Armstrong
-
Itamar Turner-Trauring
-
Tobias Oberstein