MCPcopy
hub / github.com/scrapy/scrapy / enqueue_scrape

Method enqueue_scrape

scrapy/core/scraper.py:217–236  ·  view source on GitHub ↗
(
        self, result: Response | Failure, request: Request
    )

Source from the content-addressed store, hash-verified

215
216 @inlineCallbacks
217 def enqueue_scrape(
218 self, result: Response | Failure, request: Request
219 ) -> Generator[Deferred[Any], Any, None]:
220 if self.slot is None:
221 raise RuntimeError("Scraper slot not assigned")
222 dfd = self.slot.add_response_request(result, request)
223 self._scrape_next()
224 try:
225 yield dfd # fired in _wait_for_processing()
226 except Exception:
227 logger.error(
228 "Scraper bug processing %(request)s",
229 {"request": request},
230 exc_info=True,
231 extra={"spider": self.crawler.spider},
232 )
233 finally:
234 self.slot.finish_response(result, request)
235 self._check_if_closing()
236 self._scrape_next()
237
238 def _scrape_next(self) -> None:
239 assert self.slot is not None # typing

Callers 1

Calls 5

_scrape_nextMethod · 0.95
_check_if_closingMethod · 0.95
add_response_requestMethod · 0.80
errorMethod · 0.80
finish_responseMethod · 0.80

Tested by

no test coverage detected