Several timers base on Python
Project description
diff_timer
This package includes several timers base on Python.
Timer: base on list
HeapTimer: base on heap
WheelTimer: base on Timing Wheel
Explanation
controller: The Object which is used to create different timers
tick: The time interval which is determined by you
tps: tick per second
Installation
pip install diff_timer
How to use
1、Instantiation
from controller import Controller
INTERVAL = 5
tps = 50
controller = Controller()
controller.initTimer("WHEEL", INTERVAL, tps)
2、We need a time driver
TIME_GAP = 1 / tps # 1 / 50 = 0.02
curTick = 0
while True:
time.sleep(TIME_GAP)
controller.tick(curTick)
curTick += 1
3、set timer at any place that you want
from controller import setTimeOut
def test():
print("this is a test func")
setTimeOut(test, 10, "test_func")
example: test.py
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
diff_timer-0.1.3.tar.gz
(9.1 kB
view hashes)
Built Distribution
diff_timer-0.1.3-py3-none-any.whl
(10.8 kB
view hashes)
Close
Hashes for diff_timer-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ad08a152c5b5d5852779dc6b345227aa4d881841f4e2ea74ba671351c23598c |
|
MD5 | 9d0b14a73ccc13a7de5474e5aef28aff |
|
BLAKE2b-256 | 892d900d5e60d03a5ff8bb5ae8a89c84ac2246d8f19f058661f69f684ee7f78c |