Twisted TimerService的使用(以及由此带来的诡异事件)
2009-05-05 15:28
591 查看
TimerService是twisted里提供的一个对loopingcall的service封装。
是在服务运行的期间反复执行某个方法的手段。
文档里没有,其实也很简单。
现在twistd -noy 一下,应该看到服务正常循环调用。
换个log方式,以twisted log的方法。
还能运行嘛?
在我的Mac Osx下没法子运行了。
reactor根本就没有启动。
我没有找到相关的资料。
权当做一个注意事项了。
是在服务运行的期间反复执行某个方法的手段。
文档里没有,其实也很简单。
#! /usr/bin/python # -*- coding: utf-8 -*- ''' Created on May 5, 2009 @author: Daniel ''' from twisted.application import service, internet from twisted.application.internet import TimerService from twisted.python import log import sys #log.startLogging(sys.stdout) #log.startLogging(open('./log.txt', 'w')) application = service.Application('RSSServer') def test(): #log.msg('looping') print 'looping' ts = TimerService(1, test) ts.setServiceParent(application)
现在twistd -noy 一下,应该看到服务正常循环调用。
换个log方式,以twisted log的方法。
#! /usr/bin/python # -*- coding: utf-8 -*- ''' Created on May 5, 2009 @author: Daniel ''' from twisted.application import service, internet from twisted.application.internet import TimerService from twisted.python import log import sys log.startLogging(sys.stdout) #log.startLogging(open('./log.txt', 'w')) application = service.Application('RSSServer') def test(): log.msg('looping') #print 'looping' ts = TimerService(1, test) ts.setServiceParent(application)
还能运行嘛?
在我的Mac Osx下没法子运行了。
reactor根本就没有启动。
我没有找到相关的资料。
权当做一个注意事项了。
相关文章推荐
- Android中Preference的使用以及监听事件分析
- Android 四大组件 Service实现原理以及AIDL语言的使用详解
- Android中Preference的使用以及监听事件分析
- NewRowNeeded和UserAddedRow事件以及RowsAdded的区别使用
- 使用wx.Timer来设置定时事件
- Android中Preference的使用以及监听事件分析
- Android学习之Service命令的使用以及am的用法
- Extjs 中Tabpanel使用以及tab切换事件
- ajaxToolkit:AutoCompleteExtender 的触发选择事件以及JSON序列化和使用键值 3ff8 对
- ServiceStack.Redis的使用以及Redis的数据类型
- Android中Preference的使用以及监听事件分析
- Android中Preference的使用以及监听事件分析
- cocos2dx-3.6 开发技巧(二)回调函数以及动画的使用,触摸事件,android返回键,屏幕截屏
- Boost.asio的简单使用(timer,thread,io_service类)
- Android中Preference的使用以及监听事件分析
- 关于Qt的事件循环以及QEventLoop的简单使用
- Android中Preference的使用以及监听事件分析
- UIButton 使用不规则图片,以及 长按短按事件
- SQL Server扩展事件的使用ring_buffer target时“丢失”事件的原因分析以及ring_buffer target潜在的问题
- Android中Preference的使用以及监听事件分析