def next_message(self):
if self._is_running:<EOL><INDENT>raise Exception('<STR_LIT>')<EOL><DEDENT>if self._pending_messages:<EOL><INDENT>return self._pending_messages.popleft()<EOL><DEDENT>self._async_session.run(self._enqueue_request_and_stop,<EOL>self._enqueue_notification_and_stop)<EOL>if self._pending_messages:<EOL><INDENT>return self._pending_messages.popleft()<EOL><DEDENT>
Block until a message(request or notification) is available.

        If any messages were previously enqueued, return the first in queue.
        If not, run the event loop until one is received.