To answer my own question, it looks like i can just pass sqlalchemy's
ResultProxy into deferToThread to make a blocking call to fetch the next
set of results:
@defer.inlineCallbacks
def stream_results():
engine = sqlalchemy.create_engine(...)
query = "select * from table"
proxy = yield
I'm trying to use sqlalchemy from a twisted application (by running all
blocking queries using deferToThread). Is it possible to yield from within
the function running in deferToThread? For example:
def threadRunQuery(engine, query):
conn = engine.connect()
res = conn.execute(query)