Skip to content

Commit

Permalink
added Spider.dont_throttle attribute to disable AutoThrottle extensio…
Browse files Browse the repository at this point in the history
…n per spider
pablohoffman committed May 22, 2011
1 parent 88dbe2a commit 110cd05
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scrapy/contrib/throttle.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from scrapy.xlib.pydispatch import dispatcher
from scrapy.utils.python import setattr_default
from scrapy import signals

class AutoThrottle(object):
@@ -70,16 +71,23 @@ def __init__(self):
self.last_lat = {}

def spider_opened(self, spider):
setattr_default(spider, 'dont_throttle', False)
if spider.dont_throttle:
return
spider.download_delay = self.START_DELAY
spider.max_concurrent_requests = 1
self.last_latencies[spider] = [self.START_DELAY]
self.last_lat[spider] = self.START_DELAY, 0.0

def spider_closed(self, spider):
if spider.dont_throttle:
return
del self.last_latencies[spider]
del self.last_lat[spider]

def response_received(self, response, spider):
if spider.dont_throttle:
return
latency = response.meta.get('download_latency')
if not latency:
return

0 comments on commit 110cd05

Please sign in to comment.