简体   繁体   中英

Can't stop Scrapy from inside pipeline.py

So I am writing a validator for my Scrapy data and want the spider to stop crawling if the data is in an incorrect format. I am doing this in Pipeline.py.

I have already tried calling CloseSpider, close_spider and crawler._signal_shutdown(9,0) (which have been used in other tutorials but for some reason don't work in pipeline.py). I am aware that the spider does not finish straight away but all the above methods seem to yield some sort of error. Is there just a straight forward way to kill the crawler?

Your scraper still working because of its schedule some amount of request and CloseSpider was created for a graceful shutdown. It means that all request that is in progress will be canceled or done before crawler will be closed. Do you call close_spider() in this way

只需尝试下面的代码即可消除Spider的过程:

raise SystemExit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM