Skip to content

euroeval.async_utils

source module euroeval.async_utils

Utility functions for asyncronous tasks.

Functions

source safe_run(coroutine: t.Coroutine[t.Any, t.Any, T])T

Run a coroutine, ensuring that the event loop is always closed when we're done.

Parameters

  • coroutine : t.Coroutine[t.Any, t.Any, T] The coroutine to run.

Returns

  • T The result of the coroutine.

source async add_semaphore_and_catch_exception(coroutine: t.Coroutine[t.Any, t.Any, T], semaphore: asyncio.Semaphore)T | Exception

Run a coroutine with a semaphore.

Parameters

  • coroutine : t.Coroutine[t.Any, t.Any, T] The coroutine to run.

  • semaphore : asyncio.Semaphore The semaphore to use.

Returns

  • T | Exception The result of the coroutine.