-
Notifications
You must be signed in to change notification settings - Fork 34
Added sink commitment following qgis-pull-request #59241 #333
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
base: main
Are you sure you want to change the base?
Conversation
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.
Hey,
in general, I'm all for cleaning up.
In this case, however, it seems like this doesn't do the right thing, at least not in the current implementation?
@@ -252,6 +252,12 @@ def processAlgorithm( | |||
|
|||
feedback.setProgress(int(100.0 / count * num)) | |||
|
|||
sink.flushBuffer() |
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.
According to the linked PR, we should check the return value and notify the user.
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 for whatever reason this should work, but doesn't work in all versions:
https://github.com/qgis/QGIS/pull/59241/files (so finalize was added)
https://github.com/qgis/QGIS/blob/master/src/core/processing/qgsprocessingutils.h#L811 - from 3.42 onwards this seems to be mandatory.
if hasattr(sink, "finalize"): | ||
sink.finalize() |
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.
Are there sinks that have a finalize
method? I couldn't find any.
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.
The finalize() method was added in the linked PR (Nov 12, 2024), so every version after that should have the finalize method (3.42, I think).
else: | ||
del sink |
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.
Why does the sink get deleted?
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.
Some versions before the linked PR this was a workaround so that all data is really written down to file. This triggers the write process. Will be obsolete on newer versions.
I had trouble with long running tasks. At some point feature would be added to sink, but didn't manage to arrive at the returned layer. So something in the flush of the sink went wrong. I can't really tell why and how, but this seems to fix it.
Following QGIS-Pull-Request qgis/QGIS#59241