Buckets:

download
raw
999 Bytes
import asyncio
import threading
from collections.abc import Coroutine
from typing import Any, TypeVar
T = TypeVar("T")
def run_sync(
coro: Coroutine[Any, Any, T],
running_loop: asyncio.AbstractEventLoop | None = None,
timeout: float | None = None,
) -> T | None:
result = None
exception = None
def runner() -> None:
nonlocal result, exception, running_loop
try:
try:
if not running_loop:
running_loop = asyncio.get_running_loop()
result = asyncio.run_coroutine_threadsafe(coro, running_loop).result(timeout)
except RuntimeError:
result = asyncio.run(coro)
except Exception as e:
exception = e
thread = threading.Thread(target=runner)
thread.start()
thread.join(timeout)
if thread.is_alive():
raise asyncio.TimeoutError("Coroutine execution timed out.")
if exception:
raise exception
return result

Xet Storage Details

Size:
999 Bytes
·
Xet hash:
2c85c7dfe3b02ee56f729d310803d23d0ce0ef933b9e943f5fb3997cb4d020a1

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.