Created
March 14, 2012 00:50
-
-
Save verma/2033072 to your computer and use it in GitHub Desktop.
A simple program running a dummy service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# test.py | |
from twisted.application import internet, service | |
from twisted.python import log | |
from twisted.python.logfile import DailyLogFile | |
from twisted.internet.task import LoopingCall | |
import os | |
class MyService(service.Service): | |
def startService(self): | |
service.Service.startService(self) | |
self.call = LoopingCall(log.msg, 'This is a test message.') | |
self.call.start(1.0) | |
def stopService(self): | |
self.call.cancel() | |
return service.Service.stopService(self) | |
log.startLogging(DailyLogFile("message.log", '/tmp')) | |
application = service.Application("Test Application") | |
my_service = MyService() | |
my_service.setServiceParent(application) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment