def listen(self):
pubsub = self.conn.pubsub()<EOL>pubsub.subscribe(self.pubsub_channel)<EOL>logger.debug("<STR_LIT>", self.pubsub_channel)<EOL>for msg in pubsub.listen():<EOL><INDENT>logger.debug("<STR_LIT>", str(msg['<STR_LIT:type>']))<EOL>if msg['<STR_LIT:type>'] != '<STR_LIT:message>':<EOL><INDENT>logger.debug("<STR_LIT>")<EOL>continue<EOL><DEDENT>data = pickle.loads(msg['<STR_LIT:data>'])<EOL>job_id = data['<STR_LIT>']<EOL>job = rq.job.Job.fetch(job_id, connection=self.conn)<EOL>if data['<STR_LIT:status>'] == '<STR_LIT>':<EOL><INDENT>logging.debug("<STR_LIT>", job_id)<EOL>handler = self.result_handler<EOL><DEDENT>elif data['<STR_LIT:status>'] == '<STR_LIT>':<EOL><INDENT>logging.debug("<STR_LIT>", job_id)<EOL>handler = self.result_handler_err<EOL><DEDENT>else:<EOL><INDENT>continue<EOL><DEDENT>if handler:<EOL><INDENT>logging.debug("<STR_LIT>", job_id)<EOL>handler(job)<EOL><DEDENT><DEDENT>
Listen for completed jobs and reschedule successful ones.