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

fix: catch exception on file open and release handle #117

Merged
merged 8 commits into from
Dec 8, 2022

Conversation

tlambert03
Copy link
Owner

fixes #114

@manthey ... this look good?

src/nd2/_sdk/latest.pyx Outdated Show resolved Hide resolved
@tlambert03
Copy link
Owner Author

hmm.. getting lots of segfaults in tests here, and can reproduce locally too

@tlambert03
Copy link
Owner Author

tlambert03 commented Dec 8, 2022

had to use a different approach in the cpdef function here... @manthey would be great if you could confirm that this still works for you. Thanks again for all of your help

@manthey
Copy link

manthey commented Dec 8, 2022

No. This latest commit leaves the file handle open. Specifically, the line comp_type = self._attributes().get('compressionType') doesn't throw an exception (because self._attributes() is an empty dict), so we pass through the exception handler and get to trying to get the attributes from self.attributes which fails. Maybe comp_type = self._attributes()['compressionType'] would be better to raise.

@tlambert03
Copy link
Owner Author

Specifically, the line comp_type = self._attributes().get('compressionType') doesn't throw an exception

oh right of course 🤦‍♂️ sorry!

Maybe comp_type = self._attributes()['compressionType'] would be better to raise.

don't want to assert that compressionType is always there ... but i can check that attributes is at least length 6

i updated again... when you have a moment

src/nd2/_sdk/latest.pyx Outdated Show resolved Hide resolved
@manthey
Copy link

manthey commented Dec 8, 2022

Yes, this most recent version works. I get "Unknown error reading attributes in file" and the file handle is properly closed.

@tlambert03
Copy link
Owner Author

Excellent. Thanks again for your time. Much appreciated

@tlambert03 tlambert03 merged commit 2a9416d into main Dec 8, 2022
@tlambert03 tlambert03 deleted the catch-open-err branch December 8, 2022 18:08
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

Successfully merging this pull request may close these issues.

File handle left open when an nd2 file fails to read
2 participants