diff options
| author | Claus Vium <cvium@users.noreply.github.com> | 2023-10-10 20:12:07 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-10 20:12:07 +0200 |
| commit | 733ee12ee47e2f744af5f605d82d689088b3fe9b (patch) | |
| tree | 12ec3e4cbe6ba3e5db64cb8e558ff52c8dd4b4aa /MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs | |
| parent | ba23c880f3ac5e5892a730b20ab78d8bc78d91bb (diff) | |
| parent | 4757ce105bedb075c6663d92bc1e93f87c4779f2 (diff) | |
Merge pull request #10378 from Bond-009/waitforexitasync
Use Process.WaitForExitAsync added in .NET 5
Diffstat (limited to 'MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs')
| -rw-r--r-- | MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs | 46 |
1 files changed, 16 insertions, 30 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs index a41e0b7e9..21fa4468e 100644 --- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs +++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs @@ -420,23 +420,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw; } - var ranToCompletion = await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false); - - if (!ranToCompletion) + try { - try - { - _logger.LogInformation("Killing ffmpeg subtitle conversion process"); - - process.Kill(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error killing subtitle conversion process"); - } + await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false); + exitCode = process.ExitCode; + } + catch (OperationCanceledException) + { + process.Kill(true); + exitCode = -1; } - - exitCode = ranToCompletion ? process.ExitCode : -1; } var failed = false; @@ -574,23 +567,16 @@ namespace MediaBrowser.MediaEncoding.Subtitles throw; } - var ranToCompletion = await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false); - - if (!ranToCompletion) + try { - try - { - _logger.LogWarning("Killing ffmpeg subtitle extraction process"); - - process.Kill(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error killing subtitle extraction process"); - } + await process.WaitForExitAsync(TimeSpan.FromMinutes(30)).ConfigureAwait(false); + exitCode = process.ExitCode; + } + catch (OperationCanceledException) + { + process.Kill(true); + exitCode = -1; } - - exitCode = ranToCompletion ? process.ExitCode : -1; } var failed = false; |
