MCPcopy
hub / github.com/scrapy/scrapy / install_reactor

Function install_reactor

scrapy/utils/reactor.py:112–127  ·  view source on GitHub ↗

Installs the :mod:`~twisted.internet.reactor` with the specified import path. Also installs the asyncio event loop with the specified import path if the asyncio reactor is enabled

(reactor_path: str, event_loop_path: str | None = None)

Source from the content-addressed store, hash-verified

110
111
112def install_reactor(reactor_path: str, event_loop_path: str | None = None) -> None:
113 """Installs the :mod:`~twisted.internet.reactor` with the specified
114 import path. Also installs the asyncio event loop with the specified import
115 path if the asyncio reactor is enabled"""
116 reactor_class = load_object(reactor_path)
117 if reactor_class is asyncioreactor.AsyncioSelectorReactor:
118 set_asyncio_event_loop_policy()
119 with suppress(error.ReactorAlreadyInstalledError):
120 event_loop = set_asyncio_event_loop(event_loop_path)
121 asyncioreactor.install(eventloop=event_loop)
122 else:
123 *module, _ = reactor_path.split(".")
124 installer_path = [*module, "install"]
125 installer = load_object(".".join(installer_path))
126 with suppress(error.ReactorAlreadyInstalledError):
127 installer()
128
129
130def _get_asyncio_event_loop() -> AbstractEventLoop:

Callers 15

_apply_settingsMethod · 0.90
__init__Method · 0.90
simple.pyFile · 0.90
multi_parallel.pyFile · 0.90
multi_seq.pyFile · 0.90

Calls 4

load_objectFunction · 0.90
set_asyncio_event_loopFunction · 0.85
joinMethod · 0.45

Tested by 1