-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat: split stderr for better error presentation #897
Conversation
bepri
commented
Nov 7, 2024
- Have you signed the CLA?
Adds a fork_utils module for capturing stdout/stderr separately, while also keeping a (best-effort) temporally-accurate combined account of the two.
ForkProcess now prints to the provided stdout/stderr, or nowhere at all if fileno -1 is given
StreamHandler objects were closing their pipes before guaranteeing that their associated thread wouldn't attempt to read from them again. This commit should fix that issue.
Raise a unique exception when scripts fail, that way different caller functions can decide how to handle the failure themselves
Moves the raising of ForkError from the caller to the `run()` function itself, additionally adding a `check` parameter for skipping this exception if it should be ignored.
…tibility Most tests and other modules expect `subprocess.run()` to be called, so the kwargs passed into it are given with the expectation that they'll be handled that way. Instead of changing each call one-by-one, this commit changes `fork_utils.run()` to default to the system's stdout/stderr when given `None` instead of not redirecting output at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice thanks!
Co-authored-by: Dariusz Duda <dariusz.duda@canonical.com>
Co-authored-by: Dariusz Duda <dariusz.duda@canonical.com>
To speed up the program and improve code cleanliness, proper BytesIO objects should be used and the file descriptors they read from should be wrapped in a context manager that guarantees they will be closed properly. This commit addresses both statements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for that! It will improve our UX drastically.
My last comments are rather cosmetic and you can ignore them 😄
In craft-application, it was found that tests would fail if they used the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!