Skip to content

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

per_slot_settings(docs): per slot settings - the highest priority

Georgiy Zatserklianyi98a5958687b4
diff --git a/scrapy/core/downloader/__init__.py b/scrapy/core/downloader/__init__.py
index 1a1eb819e..3691df48a 100644
--- a/scrapy/core/downloader/__init__.py
+++ b/scrapy/core/downloader/__init__.py
@@ -102,13 +102,13 @@ class Downloader:
key = self._get_slot_key(request, spider)
if key not in self.slots:
slot_settings = self.per_slot_settings.get(key, {})
- conc = slot_settings.get(
- 'concurrency', (
- self.ip_concurrency if self.ip_concurrency else self.domain_concurrency
- )
- )
+ conc = (
+ self.ip_concurrency if self.ip_concurrency else self.domain_concurrency)
conc, delay = _get_concurrency_delay(conc, spider, self.settings)
- delay = slot_settings.get('delay', delay)
+ conc, delay = (
+ slot_settings.get('concurrency', conc),
+ slot_settings.get('delay', delay)
+ )
randomize_delay = slot_settings.get('randomize_delay', self.randomize_delay)
new_slot = Slot(conc, delay, randomize_delay)
self.slots[key] = new_slot