ShardedQuery closes result too early

Issue #1228 resolved
Christian Theune created an issue

ShardedQuery._execute_and_instances creates an iterator around the result that is returned. However. In a try/finally around that return it also closes the result, causing a subsequent result.fetchall() to fail.

For me, removing the try/finally did the trick, I don't know what that breaks, though.

Comments (2)

  1. Mike Bayer repo owner

    to ensure I'm not insane, you're calling query.yield_per(x) ? otherwise query.instances() fully consumes the result set. calling fetchall() should return no rows unless you used the yield-per option.

  2. Mike Bayer repo owner

    OK I actually have fixed #1099 and it was just that the signature of query.instances() had changed but shard.py did not, so I see what you mean by the fetchall() call...you mean the fetchall() within instances (that was not clear to me). fetchall() closes the result in any case so this is 181424b743ba59ec2b6631b4d914df136757d2fd .

  3. Log in to comment