MCPcopy
hub / github.com/scrapy/scrapy / stop_async

Method stop_async

scrapy/core/engine.py:213–239  ·  view source on GitHub ↗

Gracefully stop the execution engine. .. versionadded:: 2.14

(self)

Source from the content-addressed store, hash-verified

211 return deferred_from_coro(self.stop_async())
212
213 async def stop_async(self) -> None:
214 """Gracefully stop the execution engine.
215
216 .. versionadded:: 2.14
217 """
218
219 if not self._starting:
220 raise RuntimeError("Engine not running")
221
222 self.running = self._starting = False
223 self._stopping = True
224 if self._start_request_processing_awaitable is not None:
225 if (
226 not is_asyncio_available()
227 or self._start_request_processing_awaitable
228 is not asyncio.current_task()
229 ):
230 # If using the asyncio loop and stop_async() was called from
231 # start() itself, we can't cancel it, and _start_request_processing()
232 # will exit via the self.running check.
233 self._start_request_processing_awaitable.cancel()
234 self._start_request_processing_awaitable = None
235 if self.spider is not None:
236 await self.close_spider_async(reason="shutdown")
237 await self.signals.send_catch_log_async(signal=signals.engine_stopped)
238 if self._closewait:
239 self._closewait.callback(None)
240
241 def close(self) -> Deferred[None]: # pragma: no cover
242 warnings.warn(

Callers 6

stopMethod · 0.95
close_asyncMethod · 0.95
_check_limitMethod · 0.45

Calls 5

close_spider_asyncMethod · 0.95
is_asyncio_availableFunction · 0.90
send_catch_log_asyncMethod · 0.80
callbackMethod · 0.80
cancelMethod · 0.45