Esempio n. 1
0
 public async void WorkerRestart(WorkerRestartEvent workerRestart)
 {
     if (!_disposing)
     {
         _logger.LogDebug("Handling WorkerRestartEvent for runtime:{runtime}, workerId:{workerId}", workerRestart.Language, workerRestart.WorkerId);
         await DisposeAndRestartWorkerChannel(workerRestart.Language, workerRestart.WorkerId);
     }
 }
        public async void WorkerRestart(WorkerRestartEvent workerRestart)
        {
            if (_disposing || _disposed)
            {
                return;
            }

            try
            {
                _logger.LogDebug("Handling WorkerRestartEvent for runtime:{runtime}, workerId:{workerId}", workerRestart.Language, workerRestart.WorkerId);
                await DisposeAndRestartWorkerChannel(workerRestart.Language, workerRestart.WorkerId);
            }
            catch (TaskCanceledException)
            {
                // Specifically in the "we were torn down while trying to restart" case, we want to catch here and ignore
                // If we don't catch the exception from an async void method, we'll end up tearing down the entire runtime instead
                // It's possible we want to catch *all* exceptions and log or ignore here, but taking the minimal change first
                // For example if we capture and log, we're left in a worker-less state with a working Host runtime - is that desired? Will it self recover elsewhere?
            }
        }