From 9fdc603fc39b3b4ba4a549ef038021c95cff9a20 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 5 Mar 2020 17:57:11 -0800 Subject: [PATCH] Fixed: Broken tasks getting stuck in queue --- .../Messaging/Commands/CommandExecutor.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs index bc7c0d4b8..2c9ea763e 100644 --- a/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs +++ b/src/NzbDrone.Core/Messaging/Commands/CommandExecutor.cs @@ -65,13 +65,15 @@ namespace NzbDrone.Core.Messaging.Commands private void ExecuteCommand(TCommand command, CommandModel commandModel) where TCommand : Command { - var handlerContract = typeof(IExecute<>).MakeGenericType(command.GetType()); - var handler = (IExecute)_serviceFactory.Build(handlerContract); - - _logger.Trace("{0} -> {1}", command.GetType().Name, handler.GetType().Name); + IExecute handler = null; try { + var handlerContract = typeof(IExecute<>).MakeGenericType(command.GetType()); + handler = (IExecute)_serviceFactory.Build(handlerContract); + + _logger.Trace("{0} -> {1}", command.GetType().Name, handler.GetType().Name); + _commandQueueManager.Start(commandModel); BroadcastCommandUpdate(commandModel); @@ -106,9 +108,12 @@ namespace NzbDrone.Core.Messaging.Commands { ProgressMessageContext.CommandModel = null; } - } - _logger.Trace("{0} <- {1} [{2}]", command.GetType().Name, handler.GetType().Name, commandModel.Duration.ToString()); + if (handler != null) + { + _logger.Trace("{0} <- {1} [{2}]", command.GetType().Name, handler.GetType().Name, commandModel.Duration.ToString()); + } + } } private void BroadcastCommandUpdate(CommandModel command)