[Twisted-Python] flow - a state-machine consumer
    Clark C. Evans 
    cce at clarkevans.com
       
    Fri Mar  7 00:07:35 MST 2003
    
    
  
After being convinced on IRC that my use cases arn't what Deferred
is meant to solve, Donovan "wzZzy" and I put together a first pass
at a more granular 'consumer'.  I'm now using it to build some 
fairly complicated web pages from a database, and may find its 
way into Woven (although perhaps not in its current form). 
Anyway, the tool includes:
  0. the Flow dispatcher, which is a reactor like
     mechanism driving events.
  1. a mechanism to execute a function in a thread,
     where the function returns an iterator which
     is used to generate events in the main thread.
  2. an superclass of adbapi.ConnectionPool with
     a queryChunked function which returns a result
     set incrementally (row by row) to the main 
     thread for further processing
Future plans:
  0. Work on exception handling and trapping just
     to verify that it works as coded.
  1. Incorporate some way for the reactor to 'pause'
     itself (and throw it self into the event queue)
     so that other events can be processed
  2. Update the code so that the execute to thread
     function can take an initial state for an 
     argument
  3. Update the SQL linkage so that it can take
     more than one query in parallel, sequencing
     the result sets, and returning them to a 
     shared flow object using different state
     arguments.
It isn't stable, but you can find it in CVS, or at
   http://clarkevans.com/flow.py
Comments are encouraged.
Best,
Clark
    
    
More information about the Twisted-Python
mailing list