@classmethod
    def rate(cls, rate, f, **kwargs):
        def _interval(*args, **kwargs):
            sleep_channel = Channel()
            target_timeout = timeout = 1.0 / rate
            min_timeout = 0.5 * target_timeout
            max_timeout = 1.5 * target_timeout
            last_time = time.time()
            while True:
                try:
                    sleep_channel.receive(timeout)
                except TimeoutError:
                    current_time = time.time()
                    actual_timeout = current_time - last_time
                    last_time = current_time
                    diff = actual_timeout - target_timeout
                    next_timeout = timeout - diff
                    timeout = (0.8 * timeout) + (0.2 * next_timeout)
                    if timeout > max_timeout: timeout = max_timeout
                    if timeout < min_timeout: timeout = min_timeout
                try:
                    f(current_time, *args, **kwargs)
                except TaskletExit:
                    break
                except:
                    logging.exception("unhandled exception in Tasklet.rate")
        return cls.new(_interval, **kwargs)
Creates a new task that will call *f* *rate* times per second. The main difference with :func:`interval` is that
dataset/ETHPy150Open concurrence/concurrence/lib/concurrence/core.py/Tasklet.rate