def wait_for_message(self, level, num_messages=1):
        """Wait until at least ``num_messages`` log messages have been emitted
        to the given log level."""
        while True:
            with self.lock:
                if len(self.messages[level]) >= num_messages:
                    return
                self.events[level].clear()
            self.events[level].wait(5)
dataset/ETHPy150Open jodal/pykka/tests/__init__.py/TestLogHandler.wait_for_message/original