MCPcopy
hub / github.com/scrapy/scrapy / get_reactor_settings

Function get_reactor_settings

scrapy/utils/test.py:34–57  ·  view source on GitHub ↗

Return a settings dict that works with the installed reactor. ``Crawler._apply_settings()`` checks that the installed reactor matches the settings, so tests that run the crawler in the current process may need to pass a correct :setting:`TWISTED_REACTOR` setting value when creating it.

()

Source from the content-addressed store, hash-verified

32
33
34def get_reactor_settings() -> dict[str, Any]:
35 """Return a settings dict that works with the installed reactor.
36
37 ``Crawler._apply_settings()`` checks that the installed reactor matches the
38 settings, so tests that run the crawler in the current process may need to
39 pass a correct :setting:`TWISTED_REACTOR` setting value when creating it.
40 """
41 settings: dict[str, Any] = {}
42 if is_reactor_installed():
43 if not is_asyncio_reactor_installed():
44 settings["TWISTED_REACTOR"] = None
45 else:
46 # We are either running Scrapy tests for the reactorless mode, or
47 # running some 3rd-party library tests for the reactorless mode, or
48 # running some 3rd-party library tests without initializing a reactor
49 # properly. The first two cases are fine, but we cannot distinguish the
50 # last one from them.
51 settings["TWISTED_REACTOR_ENABLED"] = False
52 settings["DOWNLOAD_HANDLERS"] = {
53 "ftp": None,
54 "http": "scrapy.core.downloader.handlers._httpx.HttpxDownloadHandler",
55 "https": "scrapy.core.downloader.handlers._httpx.HttpxDownloadHandler",
56 }
57 return settings
58
59
60def get_crawler(

Callers 9

get_raw_crawlerFunction · 0.90
_runnerMethod · 0.90
_runnerMethod · 0.90
test_crawl_multipleMethod · 0.90
get_crawlerFunction · 0.85

Calls 2

is_reactor_installedFunction · 0.90

Tested by

no test coverage detected