Scrapy, a fast high-level web crawling & scraping framework for Python.
Add ability to change max_active_size by settings
Juan Pablo Balarinieaa8ed02d05d
diff --git a/docs/topics/settings.rst b/docs/topics/settings.rstindex c02f877fc..d4480c879 100644--- a/docs/topics/settings.rst+++ b/docs/topics/settings.rst@@ -1262,6 +1262,17 @@ Type of priority queue used by the scheduler. Another available type isdomains in parallel. But currently ``scrapy.pqueues.DownloaderAwarePriorityQueue``does not work together with :setting:`CONCURRENT_REQUESTS_PER_IP`.+.. setting:: SCRAPER_SLOT_MAX_ACTIVE_SIZE++SCRAPER_SLOT_MAX_ACTIVE_SIZE+----------------------------+Default: ``5000000``++Soft limit (in bytes) for response data being processed.++While the sum of the sizes of all responses being processed is above this value,+Scrapy does not process new requests.+.. setting:: SPIDER_CONTRACTSSPIDER_CONTRACTSdiff --git a/scrapy/core/scraper.py b/scrapy/core/scraper.pyindex 99114d3bb..facbd8b73 100644--- a/scrapy/core/scraper.py+++ b/scrapy/core/scraper.py@@ -78,7 +78,7 @@ class Scraper(object):@defer.inlineCallbacksdef open_spider(self, spider):"""Open the given spider for scraping and allocate resources for it"""- self.slot = Slot()+ self.slot = Slot(self.crawler.settings.getint('SCRAPER_SLOT_MAX_ACTIVE_SIZE'))yield self.itemproc.open_spider(spider)def close_spider(self, spider):diff --git a/scrapy/settings/default_settings.py b/scrapy/settings/default_settings.pyindex d03fd37b0..ddd48d327 100644--- a/scrapy/settings/default_settings.py+++ b/scrapy/settings/default_settings.py@@ -254,6 +254,8 @@ SCHEDULER_DISK_QUEUE = 'scrapy.squeues.PickleLifoDiskQueue'SCHEDULER_MEMORY_QUEUE = 'scrapy.squeues.LifoMemoryQueue'SCHEDULER_PRIORITY_QUEUE = 'scrapy.pqueues.ScrapyPriorityQueue'+SCRAPER_SLOT_MAX_ACTIVE_SIZE = 5000000+SPIDER_LOADER_CLASS = 'scrapy.spiderloader.SpiderLoader'SPIDER_LOADER_WARN_ONLY = False