You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: Include stderr in provisioning error when log_output is set #3838
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.
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.
changed the title [-]Python: Include stderr in provisioning error[/-][+]Python: Include stderr in provisioning error when `log_output` is set[/+]on Jan 23, 2023
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.
Activity
helderco commentedon Dec 6, 2022
This is tied into logging improvements so
log_outputmay go away if favor of aloggersetting. And I also prefer for the provisioning stuff to stabilize first.Python: Add logging statements #3806[-]Python SDK: Include stderr in provisioning error[/-][+]Python: Include stderr in provisioning error[/+][-]Python: Include stderr in provisioning error[/-][+]Python: Include stderr in provisioning error when `log_output` is set[/+]helderco commentedon Jan 23, 2023
Provisioning has stabilized and #3806 has changed scope so the
loggerreplacement will take more time.helderco commentedon Jan 27, 2023
At first I was thinking on making a file proxy to pass as
stderrtosubprocess.Popenthat 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, passinglog_output=sys.stderrwould allow capturing the process errors in the raised exception.I experimented with this only to realize that
subprocessuses 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 thelog_outputfile and the in-memory buffer.Notice that the current
CLISessionimplementation 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.helderco commentedon Jul 18, 2023
To be clear, it's not worth it to make it work in sync so do it as part of #3687.