-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
50 lines (35 loc) · 888 Bytes
/
test.py
File metadata and controls
50 lines (35 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# -*- coding:utf8 -*-
# Create @ 2017-08-17 09:13:58
# Author @ 819070918@qq.com
from __future__ import with_statement
import time
from ratelimit import new_bucket
def bucket_print(bucket):
# print bucket.start_time
# print bucket.capacity
# print bucket.quantum
# print bucket.fill_interval
# print bucket.clock
# print bucket.avail
# print bucket.avail_tick
pass
def test_bucket():
fill_interval = 500
capacity = 3
bucket = new_bucket(fill_interval, capacity)
availale = bucket.take_available(2)
print availale
availale = bucket.take_available(1)
print availale
availale = bucket.take_available(1)
print availale
availale = bucket.take_available(1)
print availale
time.sleep(0.0005)
availale = bucket.take_available(2)
print availale
time.sleep(0.001)
availale = bucket.take_available(2)
print availale
if __name__ == '__main__':
test_bucket()