(domain: str, interval: float = 0.15)
| 207 | |
| 208 | |
| 209 | def _rate_limit(domain: str, interval: float = 0.15) -> None: |
| 210 | with _rate_lock: |
| 211 | now = time.monotonic() |
| 212 | last = _last_request.get(domain, 0.0) |
| 213 | next_req = max(now, last + interval) |
| 214 | _last_request[domain] = next_req |
| 215 | wait = next_req - now |
| 216 | if wait > 0: |
| 217 | time.sleep(wait) |
| 218 | |
| 219 | |
| 220 | def _get_json(url: str, domain: str) -> dict | None: |