Gracefully close the execution engine. If it has already been started, stop it. In all cases, close the spider and the downloader.
(self)
| 247 | return deferred_from_coro(self.close_async()) |
| 248 | |
| 249 | async def close_async(self) -> None: |
| 250 | """ |
| 251 | Gracefully close the execution engine. |
| 252 | If it has already been started, stop it. In all cases, close the spider and the downloader. |
| 253 | """ |
| 254 | if self.running: |
| 255 | await self.stop_async() # will also close spider and downloader |
| 256 | elif self.spider is not None: |
| 257 | await self.close_spider_async( |
| 258 | reason="shutdown" |
| 259 | ) # will also close downloader |
| 260 | elif hasattr(self, "downloader"): |
| 261 | self.downloader.close() |
| 262 | |
| 263 | def pause(self) -> None: |
| 264 | self.paused = True |