Trio Extended API (bd103.ext.trio)

Extensions to the trio package.

The Trio library contains an easy API for asynchronous Python programs. Most objects in this extension module will require asynchronous syntax, like async and await.

Note

You can install trio with:

python -m pip install -U trio
bd103.ext.trio.run_wrapper() collections.abc.Callable[source]

Allows an asynchronous function to be called from synchronous code.

This works by wrapping the function in trio.run(). Note that certain keyword arguments may cause unwanted effects because they are intercepted by trio.run().

Example

@run_wrapper()
async def do_thing():
    print("Hello!")
    await trio.sleep(3)
    print("Goodbye!")

# Instead of trio.run(do_thing)
do_thing()
Raises

ModuleNotFoundError – If trio is not installed, you will not be able to apply this decorator.