Open BishopWolf opened 4 years ago
logic.run()
is intended to be non-blocking and should stay that way.
By adding a callback, the user of the class can perform an operation when all processes complete.
Alternatively, you can add an observer to the module node and get an event every time a process state changes. This is what the GUI does to update the status display.
The other way is to use with sentences, the logic will no call exit until it finishes and the it will still be visible under context manager
I don't understand - what are sentences
in this context?
Watch the modified test examples
I'm still not following. Can you describe more specifically what you are trying to achieve and why it is not possible with the current master branch? If it helps, make a new branch and pull request with the specific suggested changes.
The proposed change was to have logic.run() as blocking until everything finishes, then it outputs results after the with
statement. The current examples leave orphans QProcesses that finish themselves way after the script has finished. I propose you to have the two behaviours:
with
statements. I will move the waiting part to the exit call.
What do you thinkI don't understand - what are
sentences
in this context?
The following is a with
sentence
with ProcessesLogic(windowTitle=labelText) as logic:
logic.run()
Okay, I see. Well, as I said I don't really see a need for a blocking version. As I mentioned, you can observe the node to track progress, or provide the callback to perform an operation when the processes all complete. Do you have a use case that cannot be satisfied with the existing behavior?
Do you have a use case that cannot be satisfied with the existing behavior?
Most of my use cases require blocking, I have pushed some changes to add blocking functionality without making it the default. Also I have added the function I use for terminate (I have a progressbar with a cancel button).
If you try to get data after logic.run(), you will realize it is executed regardless of the logic not being finished yet. One way handle this case you need to do this in the callback method, but it is extremely difficult to do this. The other way is to use with sentences, the logic will no call exit until it finishes and the it will still be visible under context manager