def throttle(period):
    """Allows only one run in a period, the rest is skipped"""
    if isinstance(period, timedelta):
        period = period.total_seconds()

    def decorator(func):

        @wraps(func)
        def wrapper(*args, **kwargs):
            now = time.time()
            if wrapper.blocked_until and wrapper.blocked_until > now:
                return
            wrapper.blocked_until = now + period

            return func(*args, **kwargs)

        wrapper.blocked_until = None
        return wrapper

    return decorator
Allows only one run in a period, the rest is skipped
funcy/flow.py