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

Clark C. Evans cce at clarkevans.com
Tue Apr 15 14:36:26 MDT 2003


On Tue, Apr 15, 2003 at 10:08:15PM +0200, Philippe Lafoucrière wrote:
| > 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).

The error handling is not a strong point of flow.py yet, but
it eventually will be.   Sorry about my last example, you
can't use QueryIterator or ThreadedIterator without using
the reactor... my bad ;)

  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

  from twisted.internet import reactor
  def finish(result): print result
  f = flow.DeferredFlow(consumer())
  f.addBoth(finish)
  reactor.callLater(2,reactor.stop)
  reactor.run()





More information about the Twisted-Python mailing list