Skip to content

hyperion.asyncutils

hyperion.asyncutils

get_loop

get_loop()

Get the current running loop or create a new one if not running.

Source code in hyperion/asyncutils.py
def get_loop() -> asyncio.AbstractEventLoop:
    """Get the current running loop or create a new one if not running."""
    try:
        return asyncio.get_running_loop()
    except RuntimeError:
        loop = asyncio.new_event_loop()
        asyncio.set_event_loop(loop)
        return loop