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")

        # Always reset the signal handling; we could have been restarted by the
        # master
        signal.signal(signal.SIGTERM, signal.SIG_DFL)

        # Each worker gets it own backend
        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 __HOLE__:
                sys.exit(1)

        self.log.info("Exiting")
dataset/ETHPy150Open thread/django-lightweight-queue/django_lightweight_queue/worker.py/Worker.run