[Twisted-Python] scheduling a task
Andrew Bennetts
andrew-twisted at puzzling.org
Fri Dec 19 19:16:04 EST 2003
On Tue, Dec 16, 2003 at 11:03:28AM +0100, enrico.sirola at riskmap.it wrote:
>
> 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
[...]
> 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?)...
Put it in the startService method of your service, i.e. A.
Also, you might find twisted.internet.task.LoopingCall to be slightly more
convenient than manually calling callLater.
-Andrew.
More information about the Twisted-Python
mailing list