[Twisted-Python] Throttling static.File

Stephen Thorne stephen at thorne.id.au
Fri Feb 6 20:37:17 EST 2004


I wanted to write a http server that would:
  - show progress of all downloads
  - only allow one http connection per file per ip
  - rate limit the connection to 4kb/sec.

now, I don't know enough about producers in order to know what
pauseProducing and resumeProducing are actually supposed to do. That
aside, I know that in the context of static.File and ThrottlingFactory,
they're doing something that doesn't work properly.

static.FileTransfer.pauseProducing is a no-op
static.FileTransfer.resumeProducing sends 63665 bytes down the

policies.ThrottlingFactory relies on how many bytes have been sent down
the connection per-second to work out if it should throttle, and to
throtte, it calls pauseProducing until the bytes/second has dropped
enough to call resumeProducing.

Basically, using these two components together didn't work, so I hacked
stuff until it did. Please bear in mind this patch should not be applied
because it breaks ThrottlingFactory for anything other than
static.File's (calling pauseProducing(pause=1) on something without
kwargs would be bad).

Is there a 'real' solution to this situation, mine is hideous.

(On another note, and this is a nevow thing, NevowSite is broken with
static.File - I had to use site.Site( MyNevowPage() ) instead of
NevowSite( MyNevowPage() - no big hassle)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch
Type: text/x-patch
Size: 3711 bytes
Desc: not available
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20040207/77154921/attachment.bin 

More information about the Twisted-Python mailing list