from twisted.application import service
class FooService(service.Service):
def startService(self):
self.foo = createFoo()
def stopService(self):
self.foo.shutdown()
del self.foo
def foobrizate(self):
# business logic!
parentSvc = service.MultiService()
svc = FooService()
svc.setServiceParent(parentSvc)