def send_at_rate(max_rate, actual_rate, total_count):  # return timedelta
    rt = RateThrottle(max_rate)
    deltaT = (1.0 / actual_rate) * 1000 * 1000  # microseconds
    startT = datetime.now()
    for each in range(int(total_count)):
        tick = datetime.now()
        rt.eventRatePause()
        tock = datetime.now()
        elapsed = timeDiffuSec(tick, tock)
        if elapsed < deltaT:
            sleep( (deltaT - elapsed) / 1000.0 / 1000.0 )
    finalT = datetime.now()
    return finalT - startT
dataset/ETHPy150Open godaddy/Thespian/thespian/system/test/test_ratelimit.py/send_at_rate/original