Example #1
0
def test_throttle():
    def func(): return _.now()

    wait = 250
    throttled = _.throttle(func, wait)

    start = _.now()
    present = _.now()

    expected = throttled()

    while (present - start) < (wait - 50):
        result = throttled()
        present = _.now()

    assert result == expected

    time.sleep(100 / 1000.0)
    assert throttled() > expected
Example #2
0
def test_throttle():
    def func():
        return _.now()

    wait = 250
    throttled = _.throttle(func, wait)

    start = _.now()
    present = _.now()

    expected = throttled()

    while (present - start) < (wait - 50):
        result = throttled()
        present = _.now()

    assert result == expected

    time.sleep(100 / 1000.0)
    assert throttled() > expected