-
Notifications
You must be signed in to change notification settings - Fork 33
Fix use after cursor closed error #830
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
Conversation
9d4d427
to
e324c2d
Compare
e324c2d
to
5020097
Compare
region_code=r.region_code, | ||
creation_time=r.creation_time, | ||
center_time=r.center_time, | ||
odc_dataset=( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since your name ends up in the git blame, you might be able to fit the parameter in a single line if you remove the parenthesis (not sure why the parenthesis was there in the first place).
You could also try taking the RHS of geometry=
and putting that on a single line without its parenthesis and then ruff format
, but I'm guessing Ruff will re-wrap that because the line is too long.
return conn.execute(query).fetchall() | ||
|
||
@contextmanager | ||
def execute_query_lazy(self, query): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the return type of this Generator[Row]
, or does the context manager decorator change the return types?
for row in result: | ||
""" | ||
with self.engine.connect() as conn: | ||
result = conn.execute(query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can yield conn.execute(query)
directly?
The cursor closed error is really annoying so happy to approve if you can get this working, the code looks fine to me (but SQLAlchemy/psycopg2 does apparently not agree with us). And I agree, the cursor closed probably happens in production as well. |
I'm going to go to bed now, but I looked at this earlier today and all the failed tests failed in the same upsert method in the postgres backend. Might be worth to rebase this onto the latest develop and let it run to see if the other test jobs also fail, or if it just is upsert that is broken. |
This should fix #667
I'm surprised it's intermittent, I would have thought it'd happen all the time, and it's probably happening in deployments too, not just in testing.
📚 Documentation preview 📚: https://datacube-explorer--830.org.readthedocs.build/en/830/