drain cursor aggressively for short result sets to avoid possible bug
drain cursor aggressively for short result sets to avoid possible bug

Psycopg2 is raising a `ProgrammingError` during cursor iteration.

The only online discussion of similar errors suggested that this error
comes from out of order reuse of a cursor. Such use isn't happening in
this code at first glance, but perhaps is due to implicit asynchrony
in the odd mix of generators, iterators, and early return
statements...?

informatics-isi-edu/hatrac,informatics-isi-edu/hatrac