import functools


def if_inactive(f):
    """decorator for callback methods so that they are only called when inactive"""

    @functools.wraps(f)
    def inner(self, loop, *args, **kwargs):
        if not self.active:
            return f(self, loop, *args, **kwargs)

    return inner