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
pip install --upgrade diff_timer
How to use
1、Instantiation
from diff_timer 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 diff_timer 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.4.tar.gz
(9.1 kB
view details)
Built Distribution
File details
Details for the file diff_timer-0.1.4.tar.gz
.
File metadata
- Download URL: diff_timer-0.1.4.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0f877c2fbcec2537fadaf41cd1712a01cae2fc4f7159340624e8cc47d83896d0
|
|
MD5 |
29e19a6b30cc9569645b7b65e3d76995
|
|
BLAKE2b-256 |
679112c9c192216f878e328e00bd23549740f6fd8a496efabbe68544ffa6f147
|
File details
Details for the file diff_timer-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: diff_timer-0.1.4-py3-none-any.whl
- Upload date:
- Size: 10.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
0dc1f31cf962e4764949494c223994456a79e931bc237f0c9cc0f0957f452611
|
|
MD5 |
cd98a49739efa3a63dd217bbecd31dce
|
|
BLAKE2b-256 |
c66025aeb79276b8f2bcd2712506cb468bd5740f0e4d27fafdc2b5aa74247bed
|