Run the event loop forever or until the task/future *task* is finished.

    :param task:
        Optional. Task or Future which is run until complete. If parameter is
        ``None`` runs the event loop forever.
    :param loop:
        Optional. Event loop to use. If the parameter is ``None`` uses
        asyncio's base event loop.

    .. note::
        This method has the same intent as :func:`aiomas.util.run`.

def run(task=None, loop=None):
    '''Run the event loop forever or until the task/future *task* is finished.

    :param task:
        Optional. Task or Future which is run until complete. If parameter is
        ``None`` runs the event loop forever.
    :param loop:
        Optional. Event loop to use. If the parameter is ``None`` uses
        asyncio's base event loop.

    .. note::
        This method has the same intent as :func:`aiomas.util.run`.
    '''
    if loop is None:
        loop = asyncio.get_event_loop()
    if task is None:
        return loop.run_forever()
    else:
        return loop.run_until_complete(task)