[Twisted-Python] Implementing an event manager in twisted

Manuel Arias manuel.arias at gmail.com
Thu Apr 12 12:40:24 EDT 2007

Hi Justin,

The scheduling is easily doable using twisted as a scheduler eg) callLater
or task.LoopingCall.

Writing an event dispatcher isn't too tough either. A very simple one allows
you to register using a hash-able "name" object eg) a string. You call the
dispatcher with the same object when you want to notify the registered
handlers. Twisted has one see:
That could easily be tied in to generating events from a listener
received data.

It seems that you have various programs that you want to coordinate using
twisted. One way to accomplish this is like you said to write an event
manager with twisted. Your listeners would connect (how? over sockets using
existing protocols or write your own...or use Perspective Broker) to your
twisted event manager to generate "received data" events. Your "received
data" event handlers could spawn processes and pipe the data to them, or you
can use twisted's adbapi to store the data in the database.

On 4/11/07, Justin Warren <daedalus at eigenmagic.com> wrote:
> Hi folks,
> I have had an idea to implement an event manager to glue a few different
> system components together, and I am wondering which pieces of twisted
> would be best suited to the task, or even if I should attempt it at all.
> I have programs that poll for data.
> I have a database that stores polled information.
> I have programs that listen for data to be provided to them from
> external entities.
> I have a desire to provide scheduler functionality (at time x, take
> action y).
> It seems to me that I could join all of these things via an event
> manager:
> A program polls for data, succeeds and notifies the event manager of the
> data that was polled. The event manager notifies a 'poll storage' object
> that stores the data in the database. It could also notify other things.
> Data is received from an external entity by a listener. The listener
> notifies the event manager of the data. The event manager notifies an
> object that stores it in the database, or runs a script, or uploads
> something to flickr, or whatever.
> Time passes. The event manager notifies interested objects that this is
> so. They take whatever action they deem necessary.
> None of this is new, so I wonder what others have done in this area? Am
> I heading down a dangerous path? What are the traps for new players? Has
> someone already written something that does all of this that I can use,
> saving myself time and headaches?
> --
> Justin Warren <daedalus at eigenmagic.com>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20070412/6d24a71d/attachment.htm 

More information about the Twisted-Python mailing list