Add deprecation warning on download_delay to throttle.py

This commit is contained in:
Hok Kan Cheung 2025-12-15 08:31:20 -05:00
parent 2686f1a37d
commit 77a0df8c7b
1 changed files with 3 additions and 0 deletions

View File

@ -5,6 +5,7 @@ from typing import TYPE_CHECKING
from scrapy import Request, Spider, signals
from scrapy.exceptions import NotConfigured
from scrapy.utils.deprecate import warn_on_deprecated_spider_attribute
if TYPE_CHECKING:
# typing.Self requires Python 3.11
@ -43,6 +44,8 @@ class AutoThrottle:
return cls(crawler)
def _spider_opened(self, spider: Spider) -> None:
if hasattr(spider, "download_delay"): # pragma: no cover
warn_on_deprecated_spider_attribute("download_delay", "DOWNLOAD_DELAY")
self.mindelay = self._min_delay(spider)
self.maxdelay = self._max_delay(spider)