import functools
import asyncio


def _cancellable(func):
    """
    Silences `asyncio.CancelledError` for an entire function.

    This way the function can be cancelled without the task ending
    with a exception, and without the function body requiring another
    indent level for the try/except.
    """
    @functools.wraps(func)
    def wrapped(*args, **kwargs):
        try:
            return func(*args, **kwargs)
        except asyncio.CancelledError:
            pass
    return wrapped