trame.utils.asynchronous module

trame.utils.asynchronous.create_task(coroutine, loop=None)

Create a task from a coroutine while also attaching a done callback so any exception or error could be caught and reported.

Parameters:
  • coroutine – A coroutine to execute as an independent task

  • loop – Optionally provide the loop on which the task should be scheduled on. By default we will use the current running loop.

Returns:

The decorated task

Return type:

asyncio.Task

trame.utils.asynchronous.decorate_task(task)

Decorate a task by attaching a done callback so any exception or error could be caught and reported.

Parameters:

task (asyncio.Task) – A coroutine to execute as an independent task

Returns:

The same task object

Return type:

asyncio.Task