def listen(self):
<EOL>db = self.config.get_database('<STR_LIT>')<EOL>kwargs = {}<EOL>if '<STR_LIT>' in self.config['<STR_LIT>']:<EOL><INDENT>kwargs['<STR_LIT>'] = self.config['<STR_LIT>']['<STR_LIT>']<EOL><DEDENT>pubsub = db.pubsub(**kwargs)<EOL>channel = self.config['<STR_LIT>'].get('<STR_LIT>', '<STR_LIT>')<EOL>pubsub.subscribe(channel)<EOL>for msg in pubsub.listen():<EOL><INDENT>if (msg['<STR_LIT:type>'] in ('<STR_LIT>', '<STR_LIT:message>') and<EOL>msg['<STR_LIT>'] == channel):<EOL><INDENT>command, _sep, args = msg['<STR_LIT:data>'].partition('<STR_LIT::>')<EOL>if not command:<EOL><INDENT>continue<EOL><DEDENT>if command[<NUM_LIT:0>] == '<STR_LIT:_>':<EOL><INDENT>LOG.error("<STR_LIT>" % command)<EOL>continue<EOL><DEDENT>if command in self._commands:<EOL><INDENT>func = self._commands[command]<EOL><DEDENT>else:<EOL><INDENT>func = utils.find_entrypoint('<STR_LIT>', command,<EOL>compat=False)<EOL>self._commands[command] = func<EOL><DEDENT>if not func:<EOL><INDENT>LOG.error("<STR_LIT>" % command)<EOL>continue<EOL><DEDENT>arglist = args.split('<STR_LIT::>') if args else []<EOL>try:<EOL><INDENT>func(self, *arglist)<EOL><DEDENT>except Exception:<EOL><INDENT>LOG.exception("<STR_LIT>" %<EOL>(command, arglist))<EOL>continue<EOL><DEDENT><DEDENT><DEDENT>
Listen for incoming control messages.

If the 'redis.shard_hint' configuration is set, its value will
be passed to the pubsub() method when setting up the
subscription.  The control channel to subscribe to is
specified by the 'redis.control_channel' configuration
('control' by default).