gevent中的定时器 timer的简单使用
来源:互联网 发布:html网页编程教程 编辑:程序博客网 时间:2024/06/01 07:52
(1)timer在gevent的core模块,core模块是对 libev库的包装,源码在:https://github.com/surfly/gevent/blob/master/gevent/core.ppyx
(2)我们可以用类loop(反应器)的timer的方法获取一个timer实例,具体函数签名如下:
def timer(self, double after, double repeat=0.0, ref=True, priority=None): return timer(self, after, repeat, ref, priority)
参数意义:
after--after秒后,第一次运行注册在此timer的回调函数(通过timer的start方法)。当为0,会马上调用回调函数,然后repeat秒后再调用回调函数。
repeat--反复运行注册的回调函数,间隔为repeat秒。默认值为0.0,即调用一次回调函数。当repeat<为正数,会持续每repeat秒回调,除非我们调用timer的stop方法。
(3)实例代码:
import geventdef test(a,b): print a,bloop = gevent.get_hub().loopt =loop.timer(0.0, 5) # timer注册回调函数后马上调用回调函数,然后反复每隔5秒调用回调函数timer.start(test,1,2)loop.run() #运行反应器loop
0 0
- gevent中的定时器 timer的简单使用
- windows服务中的定时器timer的使用
- timer 定时器的使用
- Timer定时器的使用
- 定时器Timer的使用
- Timer 定时器的使用
- timer定时器的使用
- Timer定时器的使用
- Timer定时器的使用
- java 简单的定时器Timer
- C# WidowsForm 中Timer定时器的简单使用
- java中的定时器Timer的使用及实例
- java中的定时器Timer的使用及实例
- windows服务中的定时器timer的使用 写日志
- Android中的定时器Timer、AlarmManager、CountDownTimer的使用
- Android中的定时器Timer、AlarmManager、CountDownTimer的使用
- java timer定时器的使用
- Boost::timer 定时器的使用
- 中兴ZXA10-F460 v3.0获取超级管理员密码
- 自主推荐App列表服务
- Javascript中的this关键字
- Pat(Advanced Level)Practice--1005(Spell It Right)
- 网络设备操作系统比较(Linux .vs. vxWorks)
- gevent中的定时器 timer的简单使用
- linux进程间通信之共享内存
- unity中关于Animation和AudioSource的用法
- Objective-C的Block的实现原理
- node.js学习笔记
- fzu 2137 字符串hash或者后缀数组
- 黑马程序员-基础加强04类加载 动态代理
- PHP安装pthreads多线程扩展教程[windows篇]
- ubuntu下安装谷歌拼音输入法(ibus)