[Twisted-Python] fetchmany and deferreds which call back more than once

Tommi Virtanen tv at twistedmatrix.com
Tue Mar 4 02:38:37 EST 2003

On Tue, Mar 04, 2003 at 12:15:37AM +0000, Clark C. Evans wrote:
> I have a result set with potentially 100's (1000's or more) 
> of rows from a database that I need to stream back to the 
> client after HTML formatting.  Anyway, I've looked at the
> enterprise adapter, and it only returns "once" for a given
> query with the return value of fetchall() of the cursor.
> While this is interesting, what I'd really like is a way
> to pass "chunks" of the result back via fetchmany(). 

	Here's what I've done, with LDAP queries that can
	return arbitrarily many results:


	Basically, you can either pass a callback to search() that
	will be called once per result, or if you don't pass one,
	it'll gather all the results into a list. The Deferred you
	get either evaluates to None or to a list of results,
	depending on whether you passed the callback or not.

:(){ :|:&};:

More information about the Twisted-Python mailing list