

def run(self):
    self.log = logging.getLogger()
    for x in self.log.handlers:
        self.log.removeHandler(x)
    configure_logging(level=self.log_level, format=('%%(asctime)-15s %%(process)d %s %%(levelname).1s: %%(message)s' % self.name), filename=self.log_filename)
    self.log.debug('Starting')
    signal.signal(signal.SIGTERM, signal.SIG_DFL)
    backend = get_backend()
    self.log.info('Loaded backend %s', backend)
    time_item_last_processed = datetime.datetime.utcnow()
    for item_count in itertools.count():
        if (not self.running.value):
            break
        if self.idle_time_reached(time_item_last_processed):
            self.log.info('Exiting due to reaching idle time limit')
            break
        if (item_count > 1000):
            self.log.info('Exiting due to reaching item limit')
            break
        try:
            item_processed = self.process(backend)
            if item_processed:
                time_item_last_processed = datetime.datetime.utcnow()
        except KeyboardInterrupt:
            sys.exit(1)
    self.log.info('Exiting')

dataset/ETHPy150Open thread/django-lightweight-queue/django_lightweight_queue/worker.py Worker.run/original