Ticket #601 (new defect )

Opened 5 years ago

Last modified 2 months ago

ThrottlingFactory doesn't throttle static web resource

Reported by: mg Assigned to: acapnotic
Type: defect Priority: high
Milestone: Component: web
Keywords: Cc: acapnotic, itamarst, jknight, mg
Branch: Author:
Launchpad Bug:

Attachments

Change History

  2004-04-20 04:19:05+00:00 changed by mg

A throttling factory doesn't seem to limit rates using the following tac:
----- web.tac -----
import sys
from twisted.application import internet, service
from twisted.web import server, static
from twisted.protocols import policies
application = service.Application('web')
site = server.Site(static.File('.'))
site = policies.ThrottlingFactory(site, sys.maxint, 1, 1)
webServer = internet.TCPServer(8080, site)
webServer.setServiceParent(application)
-------------------
I got the following error on 1st request although, afaict, the site still
responded ok.
---- exception -----
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/scripts/twistd.py",
line 176, in runApp
    app.runReactorWithLogging(config, oldstdout, oldstderr)
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/application/app.py",
line 90, in runReactorWithLogging
    reactor.run()
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/internet/default.py",
line 126, in run
    self.mainLoop()
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/internet/default.py",
line 134, in mainLoop
    self.runUntilCurrent()
--- <exception caught here> ---
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/internet/base.py",
line 423, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/protocols/policies.py",
line 213, in checkWriteBandwidth
    self.throttleWrites()
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/protocols/policies.py",
line 238, in throttleWrites
    p.throttleWrites()
  File
"/home/matt/python-ext//lib/python2.3/site-packages/twisted/protocols/policies.py",
line 164, in throttleWrites
    self.producer.pauseProducing()
exceptions.AttributeError: 'NoneType' object has no attribute 'pauseProducing'
--------------------

  2005-10-09 01:57:23+00:00 changed by acapnotic

Investigating.
The addition of __getattr__ on ProtocolWrapper <a
href="http://svn.twistedmatrix.com/cvs/trunk/twisted/protocols/policies.py?r1=9765&r2=9767&p1=trunk/twisted/protocols/policies.py&p2=trunk/twisted/protocols/policies.py">in
rev 9767</a>  is the cause for the traceback -- ThrottlingProtocol and its
transport end up having a namespace collision around "producer."
haven't decided if this is also the reason for the failure to limit.
Unfortunately the ThrottlingTestCase tests are marked as "skip."

  2005-10-09 03:40:17+00:00 changed by acapnotic

<keturn> brilliant!  ThrottleStuff doesn't work on web.static because
web.static..pauseProducing is defined as "pass"
<foom> keturn: as it should be.
<foom> keturn: static.File is a non-streaming-producer, which means
resumeProducing should be called once every time data is wanted
so policies.ThrottlingProtocol doesn't support non-streaming producers.  It
ignores the "streaming" argument to registerProducer and doesn't change its
behaviour accordingly.
so either fix, or have it raise exceptions when it gets non-streaming producers
registered to it.

  2008-09-23 19:17:39+00:00 changed by exarkun

  • launchpad_bug deleted
  • branch deleted
  • author deleted

This might be related to #616.

Note: See TracTickets for help on using tickets.