import asyncio


def singleton(func):
    """
    A decorator that ensures only one instance of a coroutine is running at any time.
    """
    func.lock = asyncio.Lock()

    async def func_wrapper(self, *args, **kwargs):
        if func.lock.locked():
            return

        async with func.lock:
            await func(self, *args, **kwargs)

    return func_wrapper