[Twisted-Python] scheduling a task

enrico.sirola at riskmap.it enrico.sirola at riskmap.it
Tue Dec 16 05:03:28 EST 2003


Hello,
I just wrote my first twisted python application (basically, it's a
SOAP server). The application layout is something like the following
pseudocode:

# validator.py from here
class A(service.Service):
        # .... details omitted ...
        pass

class B(resource.Resource):
        def __init__(self, service):
                self.service = service

        # .... details omitted ...


def makeService(config):
        s = service.MultiService()
        v = A()
        soap_server = internet.TCPServer(config['port'], server.Site(B(v)))
        soap_server.setServiceParent(s)
        return s
# to here

# tap.py from here 
class Options(usage.Options):

    optParameters = [
        ['port', 'p', 8090],
        ]

def makeService(config):
    return validator.makeService(config)

# to here

# plugins.tml from here
register('server', 'server.tap', 
         description = 'build a server',
	 type = 'tap', tapname = 'server')
# to here

anyway, i'd like to add the server a task running every 30s. I saw an
example using reactor, like the following:

reactor.callLater(30, task)

now, where must i put this code in order to be run at application
bootstrap? I tried putting reactor.callLater into the makeService
function, but it seems it's executed during mktap only (am i
wrong?)... 

Thanks very much in advance,
enrico

        

-- 
Enrico Sirola <enrico dot sirola at riskmap dot it>





More information about the Twisted-Python mailing list