Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterselects break if not immediately used #494

Open
emman27 opened this issue Sep 13, 2017 · 2 comments
Open

iterselects break if not immediately used #494

emman27 opened this issue Sep 13, 2017 · 2 comments

Comments

@emman27
Copy link
Contributor

emman27 commented Sep 13, 2017

Minimal example:

collection1 = db(db.table1.id > 0).iterselect(...)
collection2 = db(db.table2.id > 0).iterselect(...)
for row in collection1:
    do_something()
for row in collection2:
    do_something() # breaks

Root cause:
When the iterselect (IterRows) object is initialized, it is given a gluon.contrib.pg8000.core.Cursor attribute on iter_rows._c. At the same time, the attribute iter_rows.db._adapter is given the same Cursor.
However, since db._adapter only keeps track of the latest Cursor, after the iteration of collection1, the Cursor of db._adapter is closed - then collection2 has no cursor anymore, and cannot execute the query.

@BuhtigithuB
Copy link
Contributor

Is this related to pg8000 only or it is present in psycopg2 too??

If it limited to pg8000, consider closing this issue as pg8000 support have been droped :

d4d7e48

https://github.com/web2py/web2py/pull/1871/files#diff-0

Thanks

@niphlod
Copy link
Member

niphlod commented Mar 27, 2019

I don't know if it's possible at all to keep two iterating cursors on the same adapter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants