Sobes.tech
Junior — Senior

Call rate limiter for arbitrary function

livecode

Task condition

Create a decorator that limits the frequency of calling any function. The restriction period (in seconds) is passed to the decorator as an argument. If an attempt is made to call the function before the specified period has elapsed, an exception of type CalledTooOftenError should be raised. The decorator must work correctly with functions of any signature and preserve their original declaration.

def foo():
    print('foo')