[Twisted-Python] SQL, Threaded, and flows

Edmund Dengler edmundd at eSentire.com
Sat Aug 9 14:35:24 MDT 2003


Hi all!

I am trying the example from the Flow HowTo page, and I have into an
exception.

===========================

from __future__         import generators
from twisted.enterprise import adbapi
from twisted.internet   import reactor
from twisted.flow import flow

dbpool = adbapi.ConnectionPool("SomeDriver",host='localhost',
             db='Database',user='User',passwd='Password')

sql = """
  (SELECT 'one')
UNION ALL
  (SELECT 'two')
UNION ALL
  (SELECT 'three')
"""

def consumer():
    query = flow.Threaded(flow.QueryIterator(dbpool, sql))
    yield query
    for row in query:
        print "Processed result : ", row

from twisted.internet import reactor
def finish(result):
    print "Deferred Complete : ", result
f = flow.Deferred(consumer())
f.addBoth(finish)
reactor.callLater(1,reactor.stop)
reactor.run()

# prints
# Processed result :  ('one',)
# Processed result :  ('two',)
# Processed result :  ('three',)
# Deferred Complete:  []

===========================

> python flow-query.py
Deferred Complete :  [Failure instance: Traceback: exceptions.AttributeError, 'module' object has no attribute 'Threaded'
/opt/python/lib/python2.2/site-packages/twisted/flow/wrap.py:100:_yield
flow-query.py:18:consumer
]

Is there something I need to do? Has the API changed?

Regards!
Ed






More information about the Twisted-Python mailing list