ControlxFreak / XmasLootBox

Merry Christmas! Welcome to the 2022 Discord Christmas NFT Loot Box Advent Calendar!
1 stars 0 forks source link

Move asyncio thread decorator to a common file and import it #29

Closed ControlxFreak closed 1 year ago

ControlxFreak commented 1 year ago

I think it would be good to run the gif saving in a non-blocking thread as well so this can be reused.

def to_thread(func: Callable) -> Coroutine:
    """Helper to make these blocking functions cast to threads since they are really slow and cause Discord to freak out."""
    @functools.wraps(func)
    async def wrapper(*args, **kwargs):
        return await asyncio.to_thread(func, *args, **kwargs)
    return wrapper
ControlxFreak commented 1 year ago

I think it has been optimized enough. Things are relatively fast now