Browse Source

Add logging of pip update in updates

pull/121/head
Ionite 1 year ago
parent
commit
f9a5f8ab3d
No known key found for this signature in database
  1. 34
      StabilityMatrix.Core/Python/PyVenvRunner.cs

34
StabilityMatrix.Core/Python/PyVenvRunner.cs

@ -201,17 +201,14 @@ public class PyVenvRunner : IDisposable, IAsyncDisposable
// Record output for errors // Record output for errors
var output = new StringBuilder(); var output = new StringBuilder();
var outputAction = var outputAction = new Action<ProcessOutput>(s =>
outputDataReceived == null {
? null Logger.Debug($"Pip output: {s.Text}");
: new Action<ProcessOutput>(s => // Record to output
{ output.Append(s.Text);
Logger.Debug($"Pip output: {s.Text}"); // Forward to callback
// Record to output outputDataReceived?.Invoke(s);
output.Append(s.Text); });
// Forward to callback
outputDataReceived(s);
});
SetPyvenvCfg(PyRunner.PythonDir); SetPyvenvCfg(PyRunner.PythonDir);
RunDetached($"-m pip install {args}", outputAction); RunDetached($"-m pip install {args}", outputAction);
@ -427,9 +424,18 @@ public class PyVenvRunner : IDisposable, IAsyncDisposable
if (Process is { HasExited: false }) if (Process is { HasExited: false })
{ {
Process.Kill(); Process.Kill();
await Process try
.WaitForExitAsync(new CancellationTokenSource(1000).Token) {
.ConfigureAwait(false); await Process
.WaitForExitAsync(new CancellationTokenSource(1000).Token)
.ConfigureAwait(false);
}
catch (OperationCanceledException e)
{
Logger.Error(e, "Venv Process did not exit in time in DisposeAsync");
Process.CancelStreamReaders();
}
} }
Process = null; Process = null;

Loading…
Cancel
Save