feat: a lot of a lot

This commit is contained in:
2024-09-01 01:05:11 +03:00
parent 867dfbe597
commit 4ae03284a3
43 changed files with 700 additions and 13 deletions

0
decorators/__init__.py Normal file
View File

19
decorators/async_utils.py Normal file
View File

@@ -0,0 +1,19 @@
import asyncio
from functools import wraps
def async_to_sync(func):
@wraps(func)
def wrapper(*args, **kwargs):
# Get the current event loop
loop = asyncio.get_event_loop()
# If there is no current event loop, create a new one
if loop.is_closed():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
# Run the async function until complete and return the result
return loop.run_until_complete(func(*args, **kwargs))
return wrapper