def wrapped_f(self, f, *args, **kwargs):
        # At the first call, reset the time
        if self.__last_reset == None:
            self.__last_reset = datetime.datetime.now()

        if self.__numcalls >= self.__max_calls:
            time_delta = datetime.datetime.now() - self.__last_reset
            try:
                time_delta = int(time_delta.total_seconds()) + 1
            except __HOLE__:
                time_delta = int((time_delta.microseconds + (time_delta.seconds + time_delta.days * 24 * 3600) * 10**6) / 10**6)

            if time_delta <= self.__time_interval:
                time.sleep(self.__time_interval - time_delta + 1)
                self.__numcalls = 0
                self.__last_reset = datetime.datetime.now()

        self.__numcalls += 1
        return f(*args, **kwargs)
dataset/ETHPy150Open themiurgo/ratelim/ratelim/__init__.py/greedy.wrapped_f