Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

allow spider to set autothrottle max concurrency

Martin Olveyra175a4b5957c8
diff --git a/scrapy/contrib/throttle.py b/scrapy/contrib/throttle.py
index a1afd2c5f..69edea1ca 100644
--- a/scrapy/contrib/throttle.py
+++ b/scrapy/contrib/throttle.py
@@ -76,6 +76,9 @@ class AutoThrottle(object):
def spider_opened(self, spider):
spider.download_delay = self.START_DELAY
+ if hasattr(spider, "max_concurrent_requests"):
+ self.MAX_CONCURRENCY = spider.max_concurrent_requests
+ # override in order to avoid to initialize slot with concurrency > 1
spider.max_concurrent_requests = 1
self.last_latencies = [self.START_DELAY]
self.last_lat = self.START_DELAY, 0.0