[Twisted-Python] Re: Re: rewrite of flow.py completed

Philippe Lafoucrière lafou at wanadoo.fr
Tue Apr 15 16:08:15 EDT 2003

> It should have raised an exception if it couldn't connect.  I think
> the new flow.py (you seemed to have been using an older one) should
> fix this, but perhaps not, as I haven't tested it.  

This is weird, any exception is raised (try to change a function name in
a consumer).

> Hmm.  The following should work...
>   dbpool = adbapi.ConnectionPool("MySQLdb",
>                                 host=host,
>                                 db='MYDB',
>                                 user='USER',
>                                 passwd='PASS')
>   sql = """SELECT nom FROM dbo_questionnaire limit 0,50"""
>   def consumer()
>       query = flow.Generator(QueryIterator(dbpool, sql))
>       while 1:
>           yield query
>           if query.stop: break
>           print query.result
>   flow.Flow(consumer)
>   flow.execute()

Thank you..... I 've tried all the day to make it work, but I didn't
succeed :(

But the code above blocks and never exits.

> Or, if you want to use the twisted reactor to allow for
> more than one process...
>   from twisted.internet import reactor
>   def res(x): print "Results : ", x
>   f = flow.DeferredFlow(queryIt)
>   f.addCallback(res)
>   reactor.callLater(2,reactor.stop)
>   reactor.run()

Yes, this works (I've found it this morning). But it's still hard to use
with several producers and consumers.

> Yes.  This stuff isn't easy.

A little howto would greatly help :)
I can help you, if I understand every thing someday !

Thank you again for your help

Philippe Lafoucrière <lafou at wanadoo.fr>

More information about the Twisted-Python mailing list