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

Example needed for getting results after logic in finished #2

Open
BishopWolf opened this issue Feb 13, 2020 · 7 comments
Open

Example needed for getting results after logic in finished #2

BishopWolf opened this issue Feb 13, 2020 · 7 comments

Comments

@BishopWolf
Copy link
Contributor

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

@pieper
Copy link
Owner

pieper commented Feb 13, 2020

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?

@BishopWolf
Copy link
Contributor Author

Watch the modified test examples

@pieper
Copy link
Owner

pieper commented Feb 13, 2020

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.

@BishopWolf
Copy link
Contributor Author

BishopWolf commented Feb 14, 2020

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:

  • Non blocking linear way, current status
  • Blocking way using with statements. I will move the waiting part to the exit call.
    What do you think

@BishopWolf
Copy link
Contributor Author

BishopWolf commented Feb 14, 2020

I don't understand - what are sentences in this context?

The following is a with sentence

with ProcessesLogic(windowTitle=labelText) as logic:
    logic.run()

@pieper
Copy link
Owner

pieper commented Feb 16, 2020

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?

@BishopWolf
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants