[Twisted-Python] Throttling Factory Problem ...

Jp Calderone exarkun at intarweb.us
Sun Jul 20 16:25:37 EDT 2003

On Sun, Jul 20, 2003 at 01:46:14PM +0200, Jo?l Vennin wrote:
> Hash: SHA1
> Hello all, 
> I'm making an example to limit bandwidth with ThrottlingFactory. I've a server 
> and a client. Client and server make echo. So it's an infinite process. I've 
> limited the bandwith to 1Ko/s.
> The problem is that the client send a lot's of data  (more than the limited 
> bandwidth) during a little time. The server get all the data (more than the 
> limited bandwith) and after each wait a long of time before send/received 
> something.
> Maybe i miss something, can you help me.

  You've not actually made your protocols *respect* the limits being imposed
on it -- they just print out a message and merrily continue on their way.

  One way to do this correctly would be to set a flag in pauseProducing();
when sendSomething() is called and the flag is set, data should be held in a
buffer instead of written to the transport; when resumeProducing() is
called, any data in the buffer should be written to the transport.

  A couple things I'd like to point out: you cannot limit the number of
bytes per unit time you receive this way; to do proper limiting of that, you
need a router sitting somewhere upstream of your connection.  Second, if you
want to foist throttling onto arbitrary protocols/applications, this may not
be the best way to go about it; an external "wrapper" program can be used to
throttle an application or group of applications, such as trickled, may be
easier.  Of course, if you want to force everyone everywhere to use the
throttled version, doing it in-process is probably the only way to go.

  Hope this helps,


"If you find a neighbor in need, you're responsible for serving that
neighbor in need, you're responsible for loving a neighbor just like you'd
like to love yourself." -- George W. Bush, Sept. 16, 2002
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20030720/1c09cca3/attachment.pgp 

More information about the Twisted-Python mailing list