arthur/scheduler.py
def listen(self):
        """Listen for completed jobs and reschedule successful ones."""

        pubsub = self.conn.pubsub()
        pubsub.subscribe(self.pubsub_channel)

        logger.debug("Listening on channel %s", self.pubsub_channel)

        for msg in pubsub.listen():
            logger.debug("New message received of type %s", str(msg['type']))

            if msg['type'] != 'message':
                logger.debug("Ignoring job message")
                continue

            data = pickle.loads(msg['data'])
            job_id = data['job_id']

            job = rq.job.Job.fetch(job_id, connection=self.conn)

            if data['status'] == 'finished':
                logging.debug("Job #%s completed", job_id)
                handler = self.result_handler
            elif data['status'] == 'failed':
                logging.debug("Job #%s failed", job_id)
                handler = self.result_handler_err
            else:
                continue

            if handler:
                logging.debug("Calling handler for job #%s", job_id)
                handler(job)
def listen(self):
        """Listen for completed jobs and reschedule successful ones."""

        pubsub = self.conn.pubsub()
        pubsub.subscribe(self.pubsub_channel)

        logger.debug("Listening on channel %s", self.pubsub_channel)

        for msg in pubsub.listen():
            logger.debug("New message received of type %s", str(msg['type']))

            if msg['type'] != 'message':
                logger.debug("Ignoring job message")
                continue

            data = pickle.loads(msg['data'])
            job_id = data['job_id']

            job = rq.job.Job.fetch(job_id, connection=self.conn)

            if data['status'] == 'finished':
                logging.debug("Job #%s completed", job_id)
                handler = self.result_handler
            elif data['status'] == 'failed':
                logging.debug("Job #%s failed", job_id)
                handler = self.result_handler_err
            else:
                continue

            if handler:
                logging.debug("Calling handler for job #%s", job_id)
                handler(job)
Listen for completed jobs and reschedule successful ones.