File: runners.py

package info (click to toggle)
python-crownstone-cloud 1.4.11-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: python: 1,126; makefile: 4
file content (11 lines) | stat: -rw-r--r-- 348 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
"""Functions to run async functions from sync context"""
from __future__ import annotations

import asyncio
from collections.abc import Coroutine
from typing import Any


def run_async(coroutine: Coroutine[Any, Any, None]) -> Any:
    """Run an async function from sync context."""
    return asyncio.get_event_loop().run_until_complete(coroutine)