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
)
| 68 | |
| 69 | |
| 70 | def 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 | |
| 94 | def make_response( |
no test coverage detected