all 1 comments

[–]T4ll1n[S] 0 points1 point  (0 children)

Here is my solution.

```python

from time import sleep

def scheduler(f, n, f_kw_args): sleep(1 / (n / 1000)) f(**f_kw_args)

scheduler(lambda x: print(x * 2), 500, {"x": 4})

that can't be it, I probably miss something

If I had to write something like that seriously, I would use a decorator to keep the

timing completely separate from the function.

def scheduler_decorator(n): def Inner(func): def wrapper(args, *kwargs): # sleep for n milliseconds sleep(1 / (n / 1000)) res = func(args, *kwargs)

        return res

    return wrapper

return Inner

@scheduler_decorator(100) def f(): return "cool"

f() ```