Skip to content

Python: Include stderr in provisioning error when log_output is set #3838

Closed as not planned

Description

@helderco

Make sure to capture stderr when establishing the engine session even if log_output is set (no matter to what), so that if the provisioning fails we have an error message to show to the user.

Related:

Activity

  1. helderco commented on Dec 6, 2022

    @helderco
    ContributorAuthor

    This is tied into logging improvements so log_output may go away if favor of a logger setting. And I also prefer for the provisioning stuff to stabilize first.

  2. self-assigned this
    on Jan 5, 2023
  3. changed the title [-]Python SDK: Include stderr in provisioning error[/-] [+]Python: Include stderr in provisioning error[/+] on Jan 5, 2023
  4. changed the title [-]Python: Include stderr in provisioning error[/-] [+]Python: Include stderr in provisioning error when `log_output` is set[/+] on Jan 23, 2023
  5. helderco commented on Jan 23, 2023

    @helderco
    ContributorAuthor

    Provisioning has stabilized and #3806 has changed scope so the logger replacement will take more time.

  6. helderco commented on Jan 27, 2023

    @helderco
    ContributorAuthor

    At first I was thinking on making a file proxy to pass as stderr to subprocess.Popen that intercepts writes and fills an in-memory buffer during start up, so that if the process fails to start, the error could be read from this buffer. Therefore, passing log_output=sys.stderr would allow capturing the process errors in the raised exception.

    I experimented with this only to realize that subprocess uses low level OS calls using file descriptors directly. So the next approach is to manage a pipe, reading it in a thread and writing back to both the log_output file and the in-memory buffer.

    Notice that the current CLISession implementation is sync only, but I plan on porting it to async only, running an event loop when sync under the scene. Then, replace the thread with a coroutine.

  7. helderco commented on Jul 18, 2023

    @helderco
    ContributorAuthor

    To be clear, it's not worth it to make it work in sync so do it as part of #3687.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions