serpent/serpent/notes

24 lines
696 B
Plaintext

######### Запуск приложения под twistd
from twisted.application import internet, service
from somemodule import EchoFactory
port = 7001
factory = EchoFactory()
# this is the important bit
application = service.Application("echo") # create the Application
echoService = internet.TCPServer(port, factory) # create the service
# add the service to the application
echoService.setServiceParent(application)
#############################################
def startService(self):
service.Service.startService(self)
def stopService(self):
service.Service.stopService(self)
if self._call:
self._call.cancel()
self._call = None