MCPcopy
hub / github.com/scrapy/scrapy / _init_without_reactor

Method _init_without_reactor

scrapy/commands/shell.py:103–118  ·  view source on GitHub ↗
(self, crawler: Crawler)

Source from the content-addressed store, hash-verified

101 self._start_crawler_thread()
102
103 def _init_without_reactor(self, crawler: Crawler) -> None:
104 # Create the engine and run start_async() in the event loop thread
105 loop = self._get_reactorless_loop()
106 self._start_crawler_thread()
107
108 async def _init_engine() -> None:
109 # We may need to wait until some parts of start_async() have
110 # finished, which may need a special event in the engine and may
111 # wait until https://github.com/scrapy/scrapy/issues/6916
112 crawler.engine = crawler._create_engine()
113 loop.create_task(
114 crawler.engine.start_async(_start_request_processing=False)
115 )
116
117 future = asyncio.run_coroutine_threadsafe(_init_engine(), loop)
118 future.result()
119
120 def _get_reactorless_loop(self) -> asyncio.AbstractEventLoop:
121 assert self.crawler_process

Callers 1

runMethod · 0.95

Calls 2

_get_reactorless_loopMethod · 0.95
_start_crawler_threadMethod · 0.95

Tested by

no test coverage detected