Avoid crashing when display components are deinitialized #9568
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.
Now, try_lock (SPI & I2C) & begin_transaction (display bus core) will check that the related objects are still valid first; if they are not, the lock/begin transaction will fail by returning false, rather than "other things" such as raising a Python exception where it is not permitted, accessing invalid memory, etc.
I tested by running a version of the #9426 reproducer on a Raspberry Pi Pico. It was able to complete & soft reset multiple times with no error. I also made sure that basic display functionality still worked on a Feather ESP32S3 TFT (i.e., the REPL is still shown on the LCD when no code.py is present) and that the #8278 reproducer made the display stop updating but did not crash, including when soft-resetting the REPL.
I didn't test I2C or parallel bus bus types, epaper displays, framebuffer displays, etc. There may still be problems with these other display types & combinations.
Closes #8278 and Closes #9426