nip.utils.asyncio.run_coroutine_sync#
- nip.utils.asyncio.run_coroutine_sync(coroutine: Coroutine[Any, Any, T], timeout: float = 30) T [source]#
Run a coroutine in a synchronous context.
Copied from https://stackoverflow.com/a/78911765
- Parameters:
coroutine (Coroutine[Any, Any, T]) – The coroutine to run synchronously.
timeout (float, default=30) – The timeout for the coroutine execution, in seconds. If the coroutine does not complete within this time, a TimeoutError will be raised.
- Returns:
T – The result of the coroutine.
- Raises:
TimeoutError – If the coroutine does not complete within the specified timeout.