code: def catch_end_signal(self, signum, frame):
          
          if self.end_signal_caught:
              self.log('Previous signal caught, will end soon')
              return
  
          signal_name = dict((getattr(signal, n), n) for n in dir(signal)
                          if n.startswith('SIG') and '_' not in n).get(signum, signum)
  
          if self.status == 'running':
              self.log('Catched %s signal: stopping after current job' % signal_name,
                       level='critical')
          else:
              delay = self.timeout if self.status == 'waiting' else self.fetch_priorities_delay
              self.log('Catched %s signal: stopping in max %d seconds' % (
                       signal_name, delay), level='critical')
  
          self.end_signal_caught = self.end_forced = True
docs: When a SIGINT/SIGTERM signal is caught, this method is called, asking
          for the worker to terminate as soon as possible.