Solve warning-related issues

This commit is contained in:
Adrian Chaves 2026-06-22 11:34:08 +02:00
parent 7951f4d4d7
commit 18507ca5d5
6 changed files with 37 additions and 6 deletions

View File

@ -66,12 +66,14 @@ def get_crawler(
will be used to populate the crawler settings with a project level
priority.
"""
# When needed, useful settings can be added here, e.g. ones that prevent
# deprecation warnings.
settings: dict[str, Any] = {
**get_reactor_settings(),
**(settings_dict or {}),
}
if prevent_warnings:
settings.setdefault("CONCURRENT_REQUESTS_PER_DOMAIN", 8)
settings.setdefault("DOWNLOAD_DELAY", 0)
settings.setdefault("ROBOTSTXT_OBEY", False)
runner: CrawlerRunnerBase
if is_reactor_installed():
runner = CrawlerRunner(settings)

View File

@ -12,7 +12,14 @@ class DataSpider(Spider):
return {"data": response.text}
process = AsyncCrawlerProcess(settings={"TWISTED_REACTOR_ENABLED": False})
process = AsyncCrawlerProcess(
settings={
"TWISTED_REACTOR_ENABLED": False,
"CONCURRENT_REQUESTS_PER_DOMAIN": 8,
"DOWNLOAD_DELAY": 0,
"ROBOTSTXT_OBEY": False,
}
)
process.crawl(DataSpider)
process.start()

View File

@ -12,7 +12,14 @@ class NoRequestsSpider(scrapy.Spider):
yield
process = AsyncCrawlerProcess(settings={"TWISTED_REACTOR_ENABLED": False})
process = AsyncCrawlerProcess(
settings={
"TWISTED_REACTOR_ENABLED": False,
"CONCURRENT_REQUESTS_PER_DOMAIN": 8,
"DOWNLOAD_DELAY": 0,
"ROBOTSTXT_OBEY": False,
}
)
process.crawl(NoRequestsSpider)
process.start()

View File

@ -17,7 +17,14 @@ class DataSpider(Spider):
async def main() -> None:
configure_logging()
runner = AsyncCrawlerRunner(settings={"TWISTED_REACTOR_ENABLED": False})
runner = AsyncCrawlerRunner(
settings={
"TWISTED_REACTOR_ENABLED": False,
"CONCURRENT_REQUESTS_PER_DOMAIN": 8,
"DOWNLOAD_DELAY": 0,
"ROBOTSTXT_OBEY": False,
}
)
await runner.crawl(DataSpider)

View File

@ -17,7 +17,14 @@ class NoRequestsSpider(Spider):
async def main() -> None:
configure_logging()
runner = AsyncCrawlerRunner(settings={"TWISTED_REACTOR_ENABLED": False})
runner = AsyncCrawlerRunner(
settings={
"TWISTED_REACTOR_ENABLED": False,
"CONCURRENT_REQUESTS_PER_DOMAIN": 8,
"DOWNLOAD_DELAY": 0,
"ROBOTSTXT_OBEY": False,
}
)
await runner.crawl(NoRequestsSpider)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import asyncio
import logging
import re
import warnings
from pathlib import Path
from typing import Any, ClassVar