def run_forever(self):
        """
        Causes the worker to run either forever or until the
        ``Worker.max_tasks`` are reached.
        """
        self.starting()
        self.keep_running = True

        def handle(signum, frame):
            self.interrupt()
            self.keep_running = False

        signal.signal(signal.SIGINT, handle)

        while self.keep_running:
            if self.max_tasks and self.tasks_complete >= self.max_tasks:
                self.stopping()

            if self.gator.len():
                result = self.gator.pop()
                self.tasks_complete += 1
                self.result(result)

            if self.nap_time >= 0:
                time.sleep(self.nap_time)

        return 0
dataset/ETHPy150Open toastdriven/alligator/alligator/workers.py/Worker.run_forever/original