MCPcopy
hub / github.com/scrapy/scrapy / _schedule

Method _schedule

scrapy/shell.py:193–208  ·  view source on GitHub ↗

Send the request to the engine, wait for the result. Runs in the reactor thread.

(self, request: Request, spider: Spider | None)

Source from the content-addressed store, hash-verified

191 )
192
193 async def _schedule(self, request: Request, spider: Spider | None) -> Response:
194 """Send the request to the engine, wait for the result.
195
196 Runs in the reactor thread.
197 """
198 if self._use_reactor and is_asyncio_reactor_installed():
199 # set the asyncio event loop for the current thread
200 event_loop_path = self.crawler.settings["ASYNCIO_EVENT_LOOP"]
201 set_asyncio_event_loop(event_loop_path)
202 if not self.spider:
203 await self._open_spider(spider)
204 assert self.crawler.engine is not None
205 # send the request to the engine
206 self.crawler.engine.crawl(request)
207 # this will fire when the request callback runs (via the callback hijacking in _request_deferred())
208 return await maybe_deferred_to_future(_request_deferred(request))
209
210 async def _open_spider(self, spider: Spider | None) -> None:
211 if spider is None:

Callers 1

fetchMethod · 0.95

Calls 6

_open_spiderMethod · 0.95
set_asyncio_event_loopFunction · 0.90
maybe_deferred_to_futureFunction · 0.90
_request_deferredFunction · 0.85
crawlMethod · 0.45

Tested by

no test coverage detected