[Twisted-Python] reset/restart reactor problem

Hi All, I am porting an academic middleware project, currently implemented in C++ and Java, to python. It extensively uses multicast for communicating general events and TCP to communicate with a database. The multicast messages that I send out depend on the results that I first obtain from the database. I would prefer to serialise each of these requests in turn, but its not immediately obvious to me what the best way to do this using Twisted is. If I could reset the reactor after each client/server transaction that would be by far the easiest. I have been experimenting with threadedselectreactor, but I currently don't have an event loop as such that is independent of the reactor event loop. Nearly all the examples deal with processes that either act as servers or clients, rather than combinations of the two. Thanks in advance for any help, Joe Newman

On Sun, 25 Jun 2006 04:19:22 +0100, Joseph Newman <jfn20@cam.ac.uk> wrote:
There are quite a few possible techniques to apply here. One I would recommend is to keep a list of objects which represent pending tasks which need to be executed serially. When each task completes, pop the next one from the list and begin processing it. When a new task needs to be performed, push it onto the list.
If I could reset the reactor after each client/server transaction that would be by far the easiest.
Twisted does not currently support restartable reactors. This may be addressed someday, but I don't think this is actually the best solution to the problem you are facing.
TSR probably isn't helpful here. I would suggest something like this: class JobList: def __init__(self): self.jobs = [] def add(self, job): self.jobs.append(job) if len(self.jobs) == 1: self._doJob() def _doJob(self): job = self.jobs[0] d = job.do() d.addErrback(log.err) d.addCallback(self._finishedJob) def _finishedJob(self, result): self.jobs.pop(0) if self.jobs: self._doJob() Hope this helps, Jean-Paul

[snip code] This has already been implemented in twisted. from twisted.internet import defer requestqueue = defer.DeferredSemaphore(1) # only allow one token to be in use at a time d = requestqueue.run(object.method, arg1, arg2, arg3=3) d is a deferred that will return the result of the method call in the standard manner. The semaphore will store the function call in a FIFO queue and run it when a token becomes available, acquiring the lock, running, and releasing it once run. It allows for multiple tokens, so it's normally used to run a maximum of, say, 30 things at a time, but there's no reson not to set a maximum of 1. This guarantees that only one call in the notional queue will be run at a time, effectively serialising your requests. Keep in mind that twisted is inherently single-threaded, and hence, to an extent, serial in nature anyway, there are very few times in a twisted programme when it becomes multi-threaded, database access with twisted.enterprise being one of them. The general strategy would be to keep only the part of your programme that needs to be transactional in a queue like this, leaving the rest of the programme (like sending the multicast data) in twisted's normal asynchronous execution space. In fact, the only reason to do it this way is if you need to process the data in the order it's received. If the order is not important, then you can use your own database's transaction model to solve the concurrency issues, (see twisted.enterprise.adbapi.ConnectionPool.runInteraction), and just let twisted gets on with doing things the way it knows best. Hope this helps, Moof

Hi, I'm developping servers which communicate with webservices. I need to have looping tasks making calls every x (x depends on the task). My communication code works well but I'm not sure how to add scheduled tasks. Do I have to add a scheduler service, if so how should i go ? Or is there another way ? Thanks, Stéphane

On Tue, 27 Jun 2006 16:49:12 +0000 (GMT), Stéphane Brault <stephane_brault@yahoo.fr> wrote:
Whether or not you use a service depends on the structure of your application. If you don't use a twisted.application.internet.TimerService, you can use a twisted.internet.task.LoopingCall directly. Jean-Paul

Thanks Jean-Paul, I think I'll try to write my own service, getting inspiration from the TimerService. Stéphane ----- Message d'origine ---- De : Jean-Paul Calderone <exarkun@divmod.com> À : twisted-python@twistedmatrix.com Envoyé le : Mardi, 27 Juin 2006, 7h04mn 32s Objet : Re: [Twisted-Python] Scheduling tasks in twisted On Tue, 27 Jun 2006 16:49:12 +0000 (GMT), Stéphane Brault <stephane_brault@yahoo.fr> wrote:
Whether or not you use a service depends on the structure of your application. If you don't use a twisted.application.internet.TimerService, you can use a twisted.internet.task.LoopingCall directly. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

I'd just like to throw out an idea after working with Twisted (especially Perspective Broker) getting the early stages of my application going over the last few weeks. I love object databases... I've been using ZODB because it's so simple to work with, no SQL, just create your Python classes and all their attributes (dictionaries, references to other objects) will be pickled for you and saved in a file (or database, never tried it though)... Anyhow, I've started writing my Twisted application, where clients contact a server to get objects, edit their details, and send them back. Because ZODB works by maintaining references to other objects, I can't just replace them with the new Copyables when they come back because they are different instances. So, I compare the _p_oid attribute (object ID) with my original objects to locate the one I'm looking for, copy the __dict__ across from the Copyable to the original object, and commit the transaction. I haven't gotten much further than that, but I'm sure I'll have problems with objects which refer to other objects etc. What's great about Referenceables is that Twisted gives you the original instance when they come back to you, but the client can't access the attributes or run any of it's methods locally. What's great about Copyables is that the whole instance is sent down the wire and the client can alter it's attributes, call it's methods, and send it back... Back to the ZODB... what would be extremely useful is if clients could get an objects from the ZODB sent down to them, edit the attributes and call the methods, and sent it back and *have it be the original instance again*. Sort of like the best of both words of Referenceables and Copyables. Of course, this doesn't have to have anything to do with the ZODB, it was just my motivation for this idea. Any object could be sent down the wire, edited, and sent back having the original instance updated. My questions are: 1) Is there any way to achieve this using Twisted the way things are? 2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing? 3) I hear Zope 3 contains some kind of Twisted integration. For the life of me I can't find any information about this on the web, and I even bought a book on Zope 3 recently and the only reference to Twisted is that you can use Twisted Web instead of Zope's ZServer to service web requests. 4) I've been toying with Divmod Axiom, and I see there is Twisted Persisted (but can't find much info on it), plus there is Twisted Enterprise, but that is too close to relational databases for my liking. Do any of these projects have integration like this? 5) Does anyone else think this is a cool idea and like to see it implemented? Robert

On Wed, 28 Jun 2006 03:31:56 +0900, Robert Gravina <robert@gravina.com> wrote:
It's possible for applications or libraries which use Twisted but aren't part of Twisted to define new kinds of behavior for PB objects. You can define a class which combines the features of Referenceable and Copyable if you like. You can find some code which does something somewhat along these lines in twisted/words/service.py: for example, the PBGroup and PBGroupReference classes cooperate to make a type which, on the remote side, ends up with Python methods which make remote PB method calls as well as a single data attributes copied from the server (the attributes are effectively read-only, though - you cannot modify them and send the instance back to the server).
2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing?
If the possibility for multiple clients to interact with the same objects simultaneously exists, you will need some kind of conflict resolution. This is one reason Twisted doesn't include a class like this - different applications often want different conflict resolution behavior.
The integration is by way of WSGI. While this means that Zope3 code may be running in the same process as a Twisted reactor, you have to go a bit out of your way to get any benefit from this.
None of them do.
5) Does anyone else think this is a cool idea and like to see it implemented?
It might be interesting. I can't see any use-cases for which it is head and shoulders above a solution with looser PB coupling, but that doesn't mean one doesn't exist. :) Jean-Paul

Robert, On Tue, 27 Jun 2006 13:31:56 -0500, Robert Gravina <robert@gravina.com> wrote: [snip description of current work]
What does "have it be the original instance again" really mean? It sounds as though you simply want the distinction between Referenceables and Copyables to disappear. I smell security issues in here somewhere.
My questions are:
1) Is there any way to achieve this using Twisted the way things are?
I don't know for a certainty, but my guess is that there isn't any out-of-box solution for this. You'd have to do this yourself, I think.
2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing?
I think you really want ZEO, but I may be misunderstanding your aims.
The twisted/zope integration is really just so that zope 3 can start using twisted as a server (web, ftp, etc.). I don't think the zope community has any immediate plans to use twisted as a framework. Jim Fulton has said he wants to get out of the server business, and twisted lets him do that. I don't think he is particularly interested in using twisted to build his apps, as he already has his own framework.
As a person who uses Axiom for his current project, I say "Use Axiom!". That said, you can't use Axiom with ZODB, or vice versa. Axiom is a really great alternative to ZODB, and one that will work much more nicely with twisted, hence my endorsement of it.
5) Does anyone else think this is a cool idea and like to see it implemented?
I don't have any interest in such a thing, personally, but then again, I don't use ZODB, and hope never to do so ;) L. Daniel Burr

Actually yes, that's exactly what I want. I've been wishing I had of used that but I got the impression it was designed for making Zope more scalable, not for writing GUI apps that need to share data. http://www.zope.org/Products/ZEO/ZEOFactSheet I need authentication etc. and found Zope too scary and geared towards web-development, came across Twisted and decided to go with that. If there's any way I can use ZEO instead of Twisted PB and use Twisted for everything else, that would be perfect. I'll have to learn more about ZEO to see how this is done, but if anyone has any suggestions for this I'd love to hear about them. [snip]
Ah great... since my app is still in early stages it's not too hard to switch back to Axiom (I tried it out for a day, and liked it very much. Perhaps it will become Twisted's answer to object persistence)... I wonder if using Axiom would make this problem of updating database-stored objects with lots of references to other objects after Copyables come back any easier? Or am I just being lazy? A good bit of introspecting rich code that traverses the __dict__ recursively might be all I need. Robert

Here are a few references to Twisted and Zope together, found a few months ago. Diary for itamar - 9 Dec 2002 http://www.advogato.org/person/itamar/diary.html?start=15 TwistedZopeOpenSpaceTalk - PyCon 2004 http://www.zope.org/Members/adytumsolutions/pycon2004/TwistedZopeOpenSpaceTa... Neckar Sprint - A Zope3 Sprint in Tuebingen, Germany, Oct. 6-9, 2005 http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/NeckarSprin... zasync 1.0: Zope Product + Twisted ZEO client http://www.zope.org/Members/poster/zasync/zasync_1_0/zasync_1_0_nr (There would be another one: I have the page in my archive, but it's unreachable now, and zope.org is excluded from archive.org. That's one of the niceties of using Firefox' ScrapBook extension, instead of simple bookmarks. :-) )
An opinion definitely shared by at least Stephan Richter; see this log of an exchange between me (tekNico) and him (srichter) on IRC: IRC log of #zope3-dev for Wednesday, 2005-07-27 http://zope3.pov.lt/irclogs/%23zope3-dev.2005-07-27.log.html
I don't have any interest in such a thing, personally, but then again, I don't use ZODB, and hope never to do so ;)
Some of the reasons why one may not want to use pickle, nor ZODB, are touched upon in this interesting piece by Glyph: What Happened to Atop? http://divmod.org/trac/wiki/WhitherAtop -- Nicola Larosa - http://www.tekNico.net/ Implementation of Microsoft SOAP, a protocol running over HTTP precisely so it could bypass firewalls, should be withdrawn. [...] It is exactly this feature-above-security mindset that needs to go. -- Bruce Schneier, February 2002

On 6/27/06, Stéphane Brault <stephane_brault@yahoo.fr> wrote:
If you just need a function called every x seconds, then you can use a twisted.internet.service.TimerService attached to your application in the .tac file. If you want to do it outside the service architecture, then twisted.internet.task.LoopingCall is more your sort of thing. To my knowledge, there is no cron-style scheduler in twisted, which would allow you to run at 9:00am every day or second tuesday or schedules to that effect. You may wish to use cron to do that, running applications that connect to your daemon using pb or some other similar mechanism and trigger the action. That being said, I'm currenly considering writing such a service for twisted itself, too. Moof

Thanks Moof, in fact i need to call different functions. I didn't know about the timerservice. For the cron-style scheduler you could try googling 'zope twisted integration', there is a link to Stephen Richter's integration with a cron task. My concern was how, inside an application to launch tasks (or a looping call) at the initialization. I tried an example but it didn't seem to work. Thanks again, Stéphane ----- Message d'origine ---- De : Moof <moof@metamoof.net> À : Stéphane Brault <stephane_brault@yahoo.fr>; Twisted general discussion <twisted-python@twistedmatrix.com> Envoyé le : Mardi, 27 Juin 2006, 7h13mn 23s Objet : Re: [Twisted-Python] Scheduling tasks in twisted On 6/27/06, Stéphane Brault <stephane_brault@yahoo.fr> wrote:
If you just need a function called every x seconds, then you can use a twisted.internet.service.TimerService attached to your application in the .tac file. If you want to do it outside the service architecture, then twisted.internet.task.LoopingCall is more your sort of thing. To my knowledge, there is no cron-style scheduler in twisted, which would allow you to run at 9:00am every day or second tuesday or schedules to that effect. You may wish to use cron to do that, running applications that connect to your daemon using pb or some other similar mechanism and trigger the action. That being said, I'm currenly considering writing such a service for twisted itself, too. Moof

On Sun, 25 Jun 2006 04:19:22 +0100, Joseph Newman <jfn20@cam.ac.uk> wrote:
There are quite a few possible techniques to apply here. One I would recommend is to keep a list of objects which represent pending tasks which need to be executed serially. When each task completes, pop the next one from the list and begin processing it. When a new task needs to be performed, push it onto the list.
If I could reset the reactor after each client/server transaction that would be by far the easiest.
Twisted does not currently support restartable reactors. This may be addressed someday, but I don't think this is actually the best solution to the problem you are facing.
TSR probably isn't helpful here. I would suggest something like this: class JobList: def __init__(self): self.jobs = [] def add(self, job): self.jobs.append(job) if len(self.jobs) == 1: self._doJob() def _doJob(self): job = self.jobs[0] d = job.do() d.addErrback(log.err) d.addCallback(self._finishedJob) def _finishedJob(self, result): self.jobs.pop(0) if self.jobs: self._doJob() Hope this helps, Jean-Paul

[snip code] This has already been implemented in twisted. from twisted.internet import defer requestqueue = defer.DeferredSemaphore(1) # only allow one token to be in use at a time d = requestqueue.run(object.method, arg1, arg2, arg3=3) d is a deferred that will return the result of the method call in the standard manner. The semaphore will store the function call in a FIFO queue and run it when a token becomes available, acquiring the lock, running, and releasing it once run. It allows for multiple tokens, so it's normally used to run a maximum of, say, 30 things at a time, but there's no reson not to set a maximum of 1. This guarantees that only one call in the notional queue will be run at a time, effectively serialising your requests. Keep in mind that twisted is inherently single-threaded, and hence, to an extent, serial in nature anyway, there are very few times in a twisted programme when it becomes multi-threaded, database access with twisted.enterprise being one of them. The general strategy would be to keep only the part of your programme that needs to be transactional in a queue like this, leaving the rest of the programme (like sending the multicast data) in twisted's normal asynchronous execution space. In fact, the only reason to do it this way is if you need to process the data in the order it's received. If the order is not important, then you can use your own database's transaction model to solve the concurrency issues, (see twisted.enterprise.adbapi.ConnectionPool.runInteraction), and just let twisted gets on with doing things the way it knows best. Hope this helps, Moof

Hi, I'm developping servers which communicate with webservices. I need to have looping tasks making calls every x (x depends on the task). My communication code works well but I'm not sure how to add scheduled tasks. Do I have to add a scheduler service, if so how should i go ? Or is there another way ? Thanks, Stéphane

On Tue, 27 Jun 2006 16:49:12 +0000 (GMT), Stéphane Brault <stephane_brault@yahoo.fr> wrote:
Whether or not you use a service depends on the structure of your application. If you don't use a twisted.application.internet.TimerService, you can use a twisted.internet.task.LoopingCall directly. Jean-Paul

Thanks Jean-Paul, I think I'll try to write my own service, getting inspiration from the TimerService. Stéphane ----- Message d'origine ---- De : Jean-Paul Calderone <exarkun@divmod.com> À : twisted-python@twistedmatrix.com Envoyé le : Mardi, 27 Juin 2006, 7h04mn 32s Objet : Re: [Twisted-Python] Scheduling tasks in twisted On Tue, 27 Jun 2006 16:49:12 +0000 (GMT), Stéphane Brault <stephane_brault@yahoo.fr> wrote:
Whether or not you use a service depends on the structure of your application. If you don't use a twisted.application.internet.TimerService, you can use a twisted.internet.task.LoopingCall directly. Jean-Paul _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

I'd just like to throw out an idea after working with Twisted (especially Perspective Broker) getting the early stages of my application going over the last few weeks. I love object databases... I've been using ZODB because it's so simple to work with, no SQL, just create your Python classes and all their attributes (dictionaries, references to other objects) will be pickled for you and saved in a file (or database, never tried it though)... Anyhow, I've started writing my Twisted application, where clients contact a server to get objects, edit their details, and send them back. Because ZODB works by maintaining references to other objects, I can't just replace them with the new Copyables when they come back because they are different instances. So, I compare the _p_oid attribute (object ID) with my original objects to locate the one I'm looking for, copy the __dict__ across from the Copyable to the original object, and commit the transaction. I haven't gotten much further than that, but I'm sure I'll have problems with objects which refer to other objects etc. What's great about Referenceables is that Twisted gives you the original instance when they come back to you, but the client can't access the attributes or run any of it's methods locally. What's great about Copyables is that the whole instance is sent down the wire and the client can alter it's attributes, call it's methods, and send it back... Back to the ZODB... what would be extremely useful is if clients could get an objects from the ZODB sent down to them, edit the attributes and call the methods, and sent it back and *have it be the original instance again*. Sort of like the best of both words of Referenceables and Copyables. Of course, this doesn't have to have anything to do with the ZODB, it was just my motivation for this idea. Any object could be sent down the wire, edited, and sent back having the original instance updated. My questions are: 1) Is there any way to achieve this using Twisted the way things are? 2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing? 3) I hear Zope 3 contains some kind of Twisted integration. For the life of me I can't find any information about this on the web, and I even bought a book on Zope 3 recently and the only reference to Twisted is that you can use Twisted Web instead of Zope's ZServer to service web requests. 4) I've been toying with Divmod Axiom, and I see there is Twisted Persisted (but can't find much info on it), plus there is Twisted Enterprise, but that is too close to relational databases for my liking. Do any of these projects have integration like this? 5) Does anyone else think this is a cool idea and like to see it implemented? Robert

On Wed, 28 Jun 2006 03:31:56 +0900, Robert Gravina <robert@gravina.com> wrote:
It's possible for applications or libraries which use Twisted but aren't part of Twisted to define new kinds of behavior for PB objects. You can define a class which combines the features of Referenceable and Copyable if you like. You can find some code which does something somewhat along these lines in twisted/words/service.py: for example, the PBGroup and PBGroupReference classes cooperate to make a type which, on the remote side, ends up with Python methods which make remote PB method calls as well as a single data attributes copied from the server (the attributes are effectively read-only, though - you cannot modify them and send the instance back to the server).
2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing?
If the possibility for multiple clients to interact with the same objects simultaneously exists, you will need some kind of conflict resolution. This is one reason Twisted doesn't include a class like this - different applications often want different conflict resolution behavior.
The integration is by way of WSGI. While this means that Zope3 code may be running in the same process as a Twisted reactor, you have to go a bit out of your way to get any benefit from this.
None of them do.
5) Does anyone else think this is a cool idea and like to see it implemented?
It might be interesting. I can't see any use-cases for which it is head and shoulders above a solution with looser PB coupling, but that doesn't mean one doesn't exist. :) Jean-Paul

Robert, On Tue, 27 Jun 2006 13:31:56 -0500, Robert Gravina <robert@gravina.com> wrote: [snip description of current work]
What does "have it be the original instance again" really mean? It sounds as though you simply want the distinction between Referenceables and Copyables to disappear. I smell security issues in here somewhere.
My questions are:
1) Is there any way to achieve this using Twisted the way things are?
I don't know for a certainty, but my guess is that there isn't any out-of-box solution for this. You'd have to do this yourself, I think.
2) Is my copying-across-the-dict a good enough solution, and I should just forget about the whole thing?
I think you really want ZEO, but I may be misunderstanding your aims.
The twisted/zope integration is really just so that zope 3 can start using twisted as a server (web, ftp, etc.). I don't think the zope community has any immediate plans to use twisted as a framework. Jim Fulton has said he wants to get out of the server business, and twisted lets him do that. I don't think he is particularly interested in using twisted to build his apps, as he already has his own framework.
As a person who uses Axiom for his current project, I say "Use Axiom!". That said, you can't use Axiom with ZODB, or vice versa. Axiom is a really great alternative to ZODB, and one that will work much more nicely with twisted, hence my endorsement of it.
5) Does anyone else think this is a cool idea and like to see it implemented?
I don't have any interest in such a thing, personally, but then again, I don't use ZODB, and hope never to do so ;) L. Daniel Burr

Actually yes, that's exactly what I want. I've been wishing I had of used that but I got the impression it was designed for making Zope more scalable, not for writing GUI apps that need to share data. http://www.zope.org/Products/ZEO/ZEOFactSheet I need authentication etc. and found Zope too scary and geared towards web-development, came across Twisted and decided to go with that. If there's any way I can use ZEO instead of Twisted PB and use Twisted for everything else, that would be perfect. I'll have to learn more about ZEO to see how this is done, but if anyone has any suggestions for this I'd love to hear about them. [snip]
Ah great... since my app is still in early stages it's not too hard to switch back to Axiom (I tried it out for a day, and liked it very much. Perhaps it will become Twisted's answer to object persistence)... I wonder if using Axiom would make this problem of updating database-stored objects with lots of references to other objects after Copyables come back any easier? Or am I just being lazy? A good bit of introspecting rich code that traverses the __dict__ recursively might be all I need. Robert

Here are a few references to Twisted and Zope together, found a few months ago. Diary for itamar - 9 Dec 2002 http://www.advogato.org/person/itamar/diary.html?start=15 TwistedZopeOpenSpaceTalk - PyCon 2004 http://www.zope.org/Members/adytumsolutions/pycon2004/TwistedZopeOpenSpaceTa... Neckar Sprint - A Zope3 Sprint in Tuebingen, Germany, Oct. 6-9, 2005 http://www.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/NeckarSprin... zasync 1.0: Zope Product + Twisted ZEO client http://www.zope.org/Members/poster/zasync/zasync_1_0/zasync_1_0_nr (There would be another one: I have the page in my archive, but it's unreachable now, and zope.org is excluded from archive.org. That's one of the niceties of using Firefox' ScrapBook extension, instead of simple bookmarks. :-) )
An opinion definitely shared by at least Stephan Richter; see this log of an exchange between me (tekNico) and him (srichter) on IRC: IRC log of #zope3-dev for Wednesday, 2005-07-27 http://zope3.pov.lt/irclogs/%23zope3-dev.2005-07-27.log.html
I don't have any interest in such a thing, personally, but then again, I don't use ZODB, and hope never to do so ;)
Some of the reasons why one may not want to use pickle, nor ZODB, are touched upon in this interesting piece by Glyph: What Happened to Atop? http://divmod.org/trac/wiki/WhitherAtop -- Nicola Larosa - http://www.tekNico.net/ Implementation of Microsoft SOAP, a protocol running over HTTP precisely so it could bypass firewalls, should be withdrawn. [...] It is exactly this feature-above-security mindset that needs to go. -- Bruce Schneier, February 2002

On 6/27/06, Stéphane Brault <stephane_brault@yahoo.fr> wrote:
If you just need a function called every x seconds, then you can use a twisted.internet.service.TimerService attached to your application in the .tac file. If you want to do it outside the service architecture, then twisted.internet.task.LoopingCall is more your sort of thing. To my knowledge, there is no cron-style scheduler in twisted, which would allow you to run at 9:00am every day or second tuesday or schedules to that effect. You may wish to use cron to do that, running applications that connect to your daemon using pb or some other similar mechanism and trigger the action. That being said, I'm currenly considering writing such a service for twisted itself, too. Moof

Thanks Moof, in fact i need to call different functions. I didn't know about the timerservice. For the cron-style scheduler you could try googling 'zope twisted integration', there is a link to Stephen Richter's integration with a cron task. My concern was how, inside an application to launch tasks (or a looping call) at the initialization. I tried an example but it didn't seem to work. Thanks again, Stéphane ----- Message d'origine ---- De : Moof <moof@metamoof.net> À : Stéphane Brault <stephane_brault@yahoo.fr>; Twisted general discussion <twisted-python@twistedmatrix.com> Envoyé le : Mardi, 27 Juin 2006, 7h13mn 23s Objet : Re: [Twisted-Python] Scheduling tasks in twisted On 6/27/06, Stéphane Brault <stephane_brault@yahoo.fr> wrote:
If you just need a function called every x seconds, then you can use a twisted.internet.service.TimerService attached to your application in the .tac file. If you want to do it outside the service architecture, then twisted.internet.task.LoopingCall is more your sort of thing. To my knowledge, there is no cron-style scheduler in twisted, which would allow you to run at 9:00am every day or second tuesday or schedules to that effect. You may wish to use cron to do that, running applications that connect to your daemon using pb or some other similar mechanism and trigger the action. That being said, I'm currenly considering writing such a service for twisted itself, too. Moof
participants (7)
-
Jean-Paul Calderone
-
Joseph Newman
-
L. Daniel Burr
-
Moof
-
Nicola Larosa
-
Robert Gravina
-
Stéphane Brault