Skip to content

Commit f9a5f8a

Browse files
committed
Add logging of pip update in updates
1 parent fbfa62d commit f9a5f8a

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

StabilityMatrix.Core/Python/PyVenvRunner.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,14 @@ public async Task PipInstall(string args, Action<ProcessOutput>? outputDataRecei
201201
// Record output for errors
202202
var output = new StringBuilder();
203203

204-
var outputAction =
205-
outputDataReceived == null
206-
? null
207-
: new Action<ProcessOutput>(s =>
208-
{
209-
Logger.Debug($"Pip output: {s.Text}");
210-
// Record to output
211-
output.Append(s.Text);
212-
// Forward to callback
213-
outputDataReceived(s);
214-
});
204+
var outputAction = new Action<ProcessOutput>(s =>
205+
{
206+
Logger.Debug($"Pip output: {s.Text}");
207+
// Record to output
208+
output.Append(s.Text);
209+
// Forward to callback
210+
outputDataReceived?.Invoke(s);
211+
});
215212

216213
SetPyvenvCfg(PyRunner.PythonDir);
217214
RunDetached($"-m pip install {args}", outputAction);
@@ -427,9 +424,18 @@ public async ValueTask DisposeAsync()
427424
if (Process is { HasExited: false })
428425
{
429426
Process.Kill();
430-
await Process
431-
.WaitForExitAsync(new CancellationTokenSource(1000).Token)
432-
.ConfigureAwait(false);
427+
try
428+
{
429+
await Process
430+
.WaitForExitAsync(new CancellationTokenSource(1000).Token)
431+
.ConfigureAwait(false);
432+
}
433+
catch (OperationCanceledException e)
434+
{
435+
Logger.Error(e, "Venv Process did not exit in time in DisposeAsync");
436+
437+
Process.CancelStreamReaders();
438+
}
433439
}
434440

435441
Process = null;

0 commit comments

Comments
 (0)