MCPcopy
hub / github.com/scrapy/scrapy / start_async

Method start_async

scrapy/core/engine.py:176–203  ·  view source on GitHub ↗

Start the execution engine. .. versionadded:: 2.14

(self, *, _start_request_processing: bool = True)

Source from the content-addressed store, hash-verified

174 )
175
176 async def start_async(self, *, _start_request_processing: bool = True) -> None:
177 """Start the execution engine.
178
179 .. versionadded:: 2.14
180 """
181 if self._starting:
182 raise RuntimeError("Engine already running")
183 self.start_time = time()
184 self._starting = True
185 await self.signals.send_catch_log_async(signal=signals.engine_started)
186 if self._stopping:
187 # band-aid until https://github.com/scrapy/scrapy/issues/6916
188 return
189 if _start_request_processing and self.spider is None:
190 # require an opened spider when not run in scrapy shell
191 return
192 self.running = True
193 self._closewait = Deferred()
194 if _start_request_processing:
195 coro = self._start_request_processing()
196 if is_asyncio_available():
197 # not wrapping in a Deferred here to avoid https://github.com/twisted/twisted/issues/12470
198 # (can happen when this is cancelled, e.g. in test_close_during_start_iteration())
199 self._start_request_processing_awaitable = asyncio.ensure_future(coro)
200 else:
201 self._start_request_processing_awaitable = Deferred.fromCoroutine(coro)
202 with contextlib.suppress(asyncio.exceptions.CancelledError):
203 await maybe_deferred_to_future(self._closewait)
204
205 def stop(self) -> Deferred[None]: # pragma: no cover
206 warnings.warn(

Callers 7

startMethod · 0.95
crawlMethod · 0.80
crawl_asyncMethod · 0.80
_init_with_reactorMethod · 0.80
_init_engineMethod · 0.80

Calls 4

is_asyncio_availableFunction · 0.90
maybe_deferred_to_futureFunction · 0.90
send_catch_log_asyncMethod · 0.80