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
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.0.tar.gz
(7.5 kB
view hashes)
Built Distributions
Close
Hashes for diff_timer-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7671f9c86367cfbb02a5b7950ab3c06a50c114e9fcf0ee64484313852ca297d |
|
MD5 | b40581ea6b2cfcf768ca2171b7503f70 |
|
BLAKE2b-256 | 0bbd506e9f40bed4f5e9e3a7b256fbe3633fd8278765e03ed1aaa27bbf3f0fcc |
Close
Hashes for diff_timer-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb57dbf020828de9a04f508a06839c7510593a7a6ebfe0e946f352033c72d7d4 |
|
MD5 | cca0ce3490272a95c3db6ead32fe49df |
|
BLAKE2b-256 | ba574ff26624e95bc03078142ed829106f4d39f1b0cd6b35c974f873c8fcdde0 |