I use Jenkins to schedule my scrapers written in Python scrapy framework. I use "closed" spider method to prepare results after scraping is done.
The problem is that if I will decide to stop my spider earlier with "stop" button in Jenkins, it sends SIGTERM twice which forces my spider to unclean shutdown.
How to force Jenkins to send SIGTERM only once, or how to handle SIGTERM signal in Scrapy to ignore second SIGTERM signal and allow spider to shutdown gracefully?