[Twisted-Python] flow - a state-machine consumer
![](https://secure.gravatar.com/avatar/8ca35506ac08cebd833ab53032896c0b.jpg?s=120&d=mm&r=g)
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
![](https://secure.gravatar.com/avatar/b3407ff6ccd34c6e7c7a9fdcfba67a45.jpg?s=120&d=mm&r=g)
On Fri, Mar 07, 2003 at 07:07:35AM +0000, Clark C. Evans wrote: [..snip..]
Comments are encouraged.
I haven't looked at flow in detail yet, but my intuition is that the state-machine and the consumer mechanism should be decoupled. I think there will be uses for a consumer/producer where a state machine is overkill -- most of the time all you really want to do is receive data occasionally, and that's it. -Andrew.
![](https://secure.gravatar.com/avatar/792121149081c9c0fd251c5bbc7691cb.jpg?s=120&d=mm&r=g)
It seems to be a little bit different from the cvs sandbox version !? I remember a longer version in cvs. Anyway, I'am going to test it today, and will report to you my feelings. see you on #twisted (nick : gravis)
![](https://secure.gravatar.com/avatar/b3407ff6ccd34c6e7c7a9fdcfba67a45.jpg?s=120&d=mm&r=g)
On Fri, Mar 07, 2003 at 07:07:35AM +0000, Clark C. Evans wrote: [..snip..]
Comments are encouraged.
I haven't looked at flow in detail yet, but my intuition is that the state-machine and the consumer mechanism should be decoupled. I think there will be uses for a consumer/producer where a state machine is overkill -- most of the time all you really want to do is receive data occasionally, and that's it. -Andrew.
![](https://secure.gravatar.com/avatar/792121149081c9c0fd251c5bbc7691cb.jpg?s=120&d=mm&r=g)
It seems to be a little bit different from the cvs sandbox version !? I remember a longer version in cvs. Anyway, I'am going to test it today, and will report to you my feelings. see you on #twisted (nick : gravis)
participants (3)
-
Andrew Bennetts
-
Clark C. Evans
-
Philippe Lafoucrière