lev.run

lev

run(fn) -> result, err

Run the event loop with a main function

Creates an event loop, spawns fn as the main coroutine, and runs the loop until all tasks complete. Returns the main task's results or nil, err if the main task errored. The caller holds that raise: the loop does not log it as an unawaited task error.

Returns nil, err when the loop cannot be made. Raises on a nested lev.run(), and when fn is not a function; neither leaves a loop behind.