All Projects → rfyiamcool → timerstack

rfyiamcool / timerstack

Licence: MIT license
timerstack was developed with timerfd future and epoll engine

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language

timerstack

介绍:

Python基于linux timerfd实现的定时器模块. 使用Epoll来监听调度timerfd. 更多介绍

需要说明的是, 社区中python timerfd 存在一些bug, 不可用呀... timerstack.c 是我用PyObject timerfd c api封装的. 我这边修复并加入Epoll监听事件重新打包一个可用的项目.

具体文档可直接参考timerfd api. linux timerfd

Install:

pip

pip install timerstack

source

git clone https://github.com/rfyiamcool/timerstack.git
cd timerstack
python setup.py install

Simple Method:

timerstack.create(): 创建一个相对时间的定时器fd timerstack.settime(): 设置新旧时间,可以简单理解为间隔时间和次数. timerstack.gettime(): 查看模式

import timerstack,os
f = timerstack.create(timerfd.CLOCK_REALTIME,0)
timerstack.settime(f,0,10,0)     #单次 10s 
timerstack.settime(f,0,0,0)      #停止 
timerstack.settime(f,0,5,5)      #每5秒钟轮一次,次数不限制
os.read(f,1024)

Test:

python scheduler.py

TO DO:

more...

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].