Send the request to the engine, wait for the result. Runs in the reactor thread.
(self, request: Request, spider: Spider | None)
| 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: |
no test coverage detected