feat: Do not exit from default Python script #106
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
When a new App is created, it is populated with a simple Python script and "bare minimum" Arduino sketch.
For initial explorations of a new system, or when troubleshooting, it is common to create very simple programs (AKA "Hello, world!"). Although a complex App will typically consist of a Python script and Arduino sketch program working in coordination, for users with prior experience with Arduino the natural approach to creating a minimal App will be to simply write some familiar Arduino sketch code, leaving the default Python script code as-is.
The App is considered to be in a "stopped" state as soon as the Python script exits. This is the correct approach, but may be confusing to users due to the fact that, except perhaps under exceptional conditions, the Arduino sketch program runs perpetually. The author of a minimal sketch-based "Hello, world!" App will find it unintuitive if their App goes into a "stopped" state immediately after starting. The previous default Python script produced exactly that result.
Change description
The default Python script is hereby changed to the more intuitive behavior of running perpetually.
Additional Notes
Arduino App Lab 0.2.0 treated the App as being in a running state until the user explicitly stopped it. So even though Arduino App CLI considered the App with the previous Python code to have stopped, App Lab provided the users with the expected behavior where they would continue to be able to see the output from the sketch program in the App Lab Serial Monitor.
This behavior changed in Arduino App Lab 0.2.4. It now considers the App to be stopped when Arduino App CLI considers it stopped. I believe the new behavior of Arduino App Lab is correct, but the users who are accustomed to their Apps having the previous behavior are interpreting this as a bug:
Reviewer checklist
main.