Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

Fix OS signal names

Jesús Losadac1916626c1b5
diff --git a/scrapy/utils/ossignal.py b/scrapy/utils/ossignal.py
index df4eee5ec..f87d5a803 100644
--- a/scrapy/utils/ossignal.py
+++ b/scrapy/utils/ossignal.py
@@ -1,17 +1,18 @@
from __future__ import absolute_import
+import signal
from twisted.internet import reactor
-import signal
signal_names = {}
for signame in dir(signal):
- if signame.startswith("SIG"):
+ if signame.startswith('SIG') and not signame.startswith('SIG_'):
signum = getattr(signal, signame)
if isinstance(signum, int):
signal_names[signum] = signame
+
def install_shutdown_handlers(function, override_sigint=True):
"""Install the given function as a signal handler for all common shutdown
signals (such as SIGINT, SIGTERM, etc). If override_sigint is ``False`` the
@@ -24,5 +25,5 @@ def install_shutdown_handlers(function, override_sigint=True):
override_sigint:
signal.signal(signal.SIGINT, function)
# Catch Ctrl-Break in windows
- if hasattr(signal, "SIGBREAK"):
+ if hasattr(signal, 'SIGBREAK'):
signal.signal(signal.SIGBREAK, function)