From 89a380ef4b29757e8b7ed5dbfe1abb837beae79f Mon Sep 17 00:00:00 2001 From: Tom Wallis Date: Fri, 15 Jul 2016 16:13:50 +0100 Subject: [PATCH] Added better signal name lookup --- rq/worker.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index f7c8c63..5de6403 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -60,12 +60,16 @@ _signames = dict((getattr(signal, signame), signame) def signal_name(signum): - # Hackety-hack-hack: is there really no better way to reverse lookup the - # signal name? If you read this and know a way: please provide a patch :) try: - return _signames[signum] + if sys.version_info[:2] >= (3, 5): + return signal.Signals(signum).name + else: + return _signames[signum] + except KeyError: return 'SIG_UNKNOWN' + except ValueError: + return 'SIG_UNKNOWN' WorkerStatus = enum(