用于线程的包装器。允许重置的计时器

resettabletimer的Python项目详细描述


resetTableTimer

Build Status

threading.Timer提供可重置计时器实现的包装器。还为测试提供假计时器。

用法

resetTableTimer

# If using python 2, import print functionfrom__future__importprint_functionfromresettabletimerimportResettableTimerdelay=5# secondsfunction=print# Create resettable timert=ResettableTimer(delay,function,["Hello"],{"end":" timer!\n"})# Starting and canceling work similarly than with threading.Timert.start()# Wait 1-5 seconds# Reset the timert.reset()# Hello should be printed after five seconds

faketimer

# If using python 2, import print functionfrom__future__importprint_functionfromresettabletimerimportFakeTimert=FakeTimer(2,print,["Hello"],{"end":" timer!\n"})# Starting and canceling work similarly than with threading.Timert.start()# Wait >2 seconds# Nothing happens# Time passage is controlled with pass_timet.pass_time(2)# Hello should be printed

测试

使用命令运行单元测试:

cd resettabletimer

python3 -m unittest discover -s tst/

使用命令获取测试覆盖率:

cd resettabletimer

coverage run -m unittest discover -s tst/
coverage report -m

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
带truezip的java拆分zip   java Spring,AppEngine:在AppEngine的数据源中添加postgresql url   java Android coverflow   java以编程方式创建复合过滤器,以在log4j 2中定义多个过滤器   java jpa eclipselink异常[eclipselink 4002]   中的java WordNet数据库目录相对路径。罐子   java无法在Spring Boot 2/3中显示登录的用户   java Onetomany:未找到联接表错误   java数据模型演化   java方法在类型列表中添加的(对象)不适用于参数(int)意味着什么?   用java打印两个数组   java SNMP4J发送从不超时   java添加/删除联系人(EditText)+类别(SpinnerBox),可以根据需要动态添加/删除多个联系人   语句和PreparedStatement之间的java差异   java在运行作为JAR归档文件分发的项目时加载图像等资源   来自应用程序或外部服务器的java Cron作业   多线程Java并发:并发添加和清除列表项   java更改单元测试的私有方法行为