Skip to main content

Overview

The loop() function creates and sets a new asyncio event loop. This is a convenience function for running nodriver’s async functions in a synchronous context.

Signature

Returns

asyncio.AbstractEventLoop
A new asyncio event loop that you can use to run async functions.

Examples

Basic usage

Running multiple coroutines

Alternative: Using asyncio directly

You can also use Python’s built-in asyncio.run() (Python 3.7+):

Notes

The loop() function is a convenience wrapper around asyncio.new_event_loop() and asyncio.set_event_loop().
In Python 3.7+, you can use asyncio.run() instead of uc.loop().run_until_complete() for simpler code.

See also