1

I don't understand how "is_child_algorithm" works in processing.run.

Premise: I created a script in python. This script uses a loop, iterating thousands of times over a field on a layer. I noticed that the ram occupation grows over time and the processing time on the single step also grows. I use different "classical" functions in the code ex:

outputs['fieldcalculator_on_layer_map1'] = processing.run ('native: fieldcalculator', alg_params, context = context, is_child_algorithm = True)
outputs ['delete_duplicate_on_layer_map1'] = processing.run ('native: deleteduplicategeometries', alg_params, context = context, is_child_algorithm = True)

I noticed that setting is_child_algorithm = False I don't have the ram and time problem (it remains constant at each step), but after several iterations (200) the program crashes, while using is_child_algorithm = True doesn't crash, of course.

What does "is_child_algorithm = True / False" do?

asked Jun 9, 2022 at 8:06
1
  • It seems like setting is_child_algorithm=False results in the outputs becoming QgsVectorLayer objects while otherwise one gets a string (as reference to a layer in the project or whatever?). Commented Mar 13, 2023 at 21:39

1 Answer 1

3

According to QGIS source code the is_child_algorithm parameter is used to indicate "if this algorithm is being run as part of a larger algorithm" (for example if a given algorithm is part of an algorithm which calls other Processing algorithms).

Internally this seems to mostly impact the way the ownership of the layers created by the algorithm is transferred (or not) to the caller.

In your case it seems that leaving this value on False is the right solution.

answered Jun 10, 2022 at 13:43

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.