MCPcopy
hub / github.com/scrapy/scrapy / check_stop_download

Function check_stop_download

scrapy/utils/_download_handlers.py:70–91  ·  view source on GitHub ↗

Send the given signal and check if any of its handlers raised :exc:`~scrapy.exceptions.StopDownload`. Return the raised exception or ``None``.

(
    signal: object, crawler: Crawler, request: Request, **kwargs: Any
)

Source from the content-addressed store, hash-verified

68
69
70def check_stop_download(
71 signal: object, crawler: Crawler, request: Request, **kwargs: Any
72) -> StopDownload | None:
73 """Send the given signal and check if any of its handlers raised
74 :exc:`~scrapy.exceptions.StopDownload`.
75
76 Return the raised exception or ``None``.
77 """
78 signal_result = crawler.signals.send_catch_log(
79 signal=signal,
80 request=request,
81 spider=crawler.spider,
82 **kwargs,
83 )
84 for handler, result in signal_result:
85 if isinstance(result, Failure) and isinstance(result.value, StopDownload):
86 logger.debug(
87 f"Download stopped for {request} from signal handler {handler.__qualname__}"
88 )
89 return result.value
90
91 return None
92
93
94def make_response(

Callers 3

_read_responseMethod · 0.90
_cb_bodyreadyMethod · 0.90
dataReceivedMethod · 0.90

Calls 1

send_catch_logMethod · 0.80

Tested by

no test coverage detected