Skip to content

Conversation

jannefleischer
Copy link
Contributor

@jannefleischer jannefleischer commented Jun 2, 2025

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

Copy link
Collaborator

@koebi koebi left a 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()
Copy link
Collaborator

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.

Copy link
Contributor Author

@jannefleischer jannefleischer Jul 1, 2025

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.

Comment on lines +256 to +257
if hasattr(sink, "finalize"):
sink.finalize()
Copy link
Collaborator

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.

Copy link
Contributor Author

@jannefleischer jannefleischer Jul 1, 2025

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).

Comment on lines +258 to +259
else:
del sink
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

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.

2 participants