Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@verma
Created March 14, 2012 00:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save verma/2033072 to your computer and use it in GitHub Desktop.
Save verma/2033072 to your computer and use it in GitHub Desktop.
A simple program running a dummy service
# 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