Buckets:
AnonymousSpottedToad/candidate_bucket / codebase /python /topoteretes_cognee /cognee /infrastructure /utils /run_async.py
| import asyncio | |
| import inspect | |
| from collections.abc import Callable | |
| from concurrent.futures import Executor | |
| from functools import partial | |
| from typing import Any, TypeVar | |
| T = TypeVar("T") | |
| async def run_async( | |
| func: Callable[..., T], | |
| *args: Any, | |
| loop: asyncio.AbstractEventLoop | None = None, | |
| executor: Executor | None = None, | |
| **kwargs: Any, | |
| ) -> T: | |
| if loop is None: | |
| try: | |
| loop = asyncio.get_running_loop() | |
| except RuntimeError: | |
| loop = asyncio.get_event_loop() | |
| if "loop" in inspect.signature(func).parameters: | |
| pfunc = partial(func, *args, loop=loop, **kwargs) | |
| else: | |
| pfunc = partial(func, *args, **kwargs) | |
| return await loop.run_in_executor(executor, pfunc) | |
Xet Storage Details
- Size:
- 748 Bytes
- Xet hash:
- f2e16befb12b0a825ceec0e6beff6eb6d28a40507891cb1ba6b3138ec50876c0
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.