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

Handle Database Cancelled Queries (a.k.a. DB Timeouts) #31

Merged
merged 3 commits into from
Jan 20, 2025

Conversation

JVickery-TBS
Copy link

fix(logic): catch db timeouts;

  • Handle database query timeouts and close tmp files.

- Handle database query timeouts and close tmp files.
@JVickery-TBS JVickery-TBS added the bug Something isn't working label Jan 8, 2025
@JVickery-TBS JVickery-TBS requested a review from wardi January 8, 2025 16:44
- Added change log file.
@wardi
Copy link
Member

wardi commented Jan 10, 2025

it's usually a good pattern to use a context manager or try: finally: to make sure resources like temp files are always closed.

Here you're closing the file within a closure that wasn't responsible for creating the file, or even passed it as a parameter. That's a little confusing and it's hard to see that the file will always be closed by looking at the code.

- File close in finally.
@JVickery-TBS
Copy link
Author

JVickery-TBS commented Jan 17, 2025

@wardi yeah the temp file comes from XLoader's _download_resource_data method, which returns the file like object and file hash as a tuple.

I kind of just coded it the same as the rest of XLoader is coded, which I guess is not great if all these try/catches and file closing is happening in enclosure methods??

But I see at the end of the method, upstream has the tmp_file.close(). So I have now put that into the finally. So if an Exception is raised the finally: tmp_file.close() will get run still right?

@JVickery-TBS JVickery-TBS merged commit cf518c8 into canada-v2.10 Jan 20, 2025
1 check passed
@JVickery-TBS JVickery-TBS deleted the fix/db-timeouts branch January 20, 2025 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants