Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diff-timer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diff-timer

Several timers base on Python

  • 0.1.4
  • PyPI
  • Socket score

Maintainers
1

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

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc