Back to tasksGet help with live coding in real time with Sobes Copilot
Junior — Senior
52
Throttle execution frequency of an arbitrary function
Task condition
Create a decorator that limits how often a given callable can be invoked. The time window (in seconds) is passed to the decorator as an argument. If the wrapped function is called again before the specified interval has passed, the decorator must raise a CalledTooOftenError. The decorator should be generic, work with any callable, and preserve the original function's signature.
def sample_func():
print('foo')