def drain_events(self, timeout=None):
chanmap = self.channels<EOL>chanid, method_sig, args, content = self._wait_multiple(<EOL>chanmap, None, timeout=timeout,<EOL>)<EOL>channel = chanmap[chanid]<EOL>if (content and<EOL>channel.auto_decode and<EOL>hasattr(content, '<STR_LIT>')):<EOL><INDENT>try:<EOL><INDENT>content.body = content.body.decode(content.content_encoding)<EOL><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>amqp_method = (self._method_override.get(method_sig) or<EOL>channel._METHOD_MAP.get(method_sig, None))<EOL>if amqp_method is None:<EOL><INDENT>raise AMQPNotImplementedError(<EOL>'<STR_LIT>'.format(method_sig))<EOL><DEDENT>if content is None:<EOL><INDENT>return amqp_method(channel, args)<EOL><DEDENT>else:<EOL><INDENT>return amqp_method(channel, args, content)<EOL><DEDENT>
Wait for an event on a channel.