{"record":{"id":"4859c31b86f64087","repo":"D4Vinci/Scrapling","slug":"autothrottle-max-delay-can-t-be-lower-than-auto","errorCode":null,"errorMessage":"`autothrottle_max_delay` can't be lower than `autothrottle_start_delay`","messagePattern":"`autothrottle_max_delay` can't be lower than `autothrottle_start_delay`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"scrapling/spiders/throttle.py","lineNumber":53,"sourceCode":"    def __init__(\n        self,\n        start_delay: float = 5.0,\n        max_delay: float = 60.0,\n        target_concurrency: float = 1.0,\n        block_backoff: bool = True,\n    ):\n        \"\"\"\n        :param start_delay: The delay used for the first request to a domain.\n        :param max_delay: The highest delay the throttle is allowed to reach.\n        :param target_concurrency: How many requests the spider aims to have in flight per domain. The engine\n            passes the spider's `concurrent_requests_per_domain` here, or 1 when it's unlimited.\n        :param block_backoff: Double the delay of a domain whenever it blocks us, or wait what its `Retry-After`\n            header asks for.\n        \"\"\"\n        if target_concurrency <= 0:\n            raise ValueError(\"`target_concurrency` must be higher than 0\")\n        if max_delay < start_delay:\n            raise ValueError(\"`autothrottle_max_delay` can't be lower than `autothrottle_start_delay`\")\n\n        self.start_delay = start_delay\n        self.max_delay = max_delay\n        self.target_concurrency = target_concurrency\n        self.block_backoff = block_backoff\n        self.delays: Dict[str, float] = {}\n\n    def delay_for(self, domain: str, floor: float = 0.0) -> float:\n        \"\"\"Return the current delay for a domain, starting it at `start_delay` the first time.\n\n        :param domain: The domain the request belongs to.\n        :param floor: The lowest delay allowed, which is the spider's own delay for this domain.\n        \"\"\"\n        if domain not in self.delays:\n            self.delays[domain] = min(max(floor, self.start_delay), self.max_delay)\n        return self.delays[domain]\n\n    def record(","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/D4Vinci/Scrapling/blob/5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f/scrapling/spiders/throttle.py#L35-L71","documentation":"AutoThrottle requires max_delay >= start_delay; the throttle ramps delay from start_delay up to max_delay, so an inverted range is invalid and construction raises ValueError. Both values come from the spider's autothrottle_start_delay / autothrottle_max_delay settings.","triggerScenarios":"Setting autothrottle_max_delay below autothrottle_start_delay on the spider class (e.g. start 5.0, max 2.0); copying delay presets where the two fields got swapped; tuning max_delay down without checking the start value.","commonSituations":"Aiming for faster crawls by lowering max_delay while the start_delay default is higher; presets/configs written for older defaults; unit tests constructing AutoThrottle with arbitrary numbers.","solutions":["Ensure autothrottle_max_delay >= autothrottle_start_delay (e.g. start 1.0, max 10.0)","If you want a constant delay, set both to the same value","Re-check both fields after tuning either one"],"exampleFix":"// before\nclass MySpider(Spider):\n    autothrottle_start_delay = 5.0\n    autothrottle_max_delay = 2.0\n\n// after\nclass MySpider(Spider):\n    autothrottle_start_delay = 1.0\n    autothrottle_max_delay = 10.0","handlingStrategy":"validation","validationCode":"assert autothrottle_max_delay >= autothrottle_start_delay, \"max_delay must be >= start_delay\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Tune both throttle fields together","Use equal values for a constant delay","Validate spider settings in a config test"],"tags":["throttle","configuration","validation"],"backgroundTag":null,"analyzedSha":"5d213a2d4764002bfc4fed33c32fe09fa8b0bf7f","analyzedAt":"2026-08-14T22:23:09.440Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}