From dccd417587a8aaf8cc8b51c4233bb2f5983dbdac Mon Sep 17 00:00:00 2001
From: Charlotte Hausman <chausman@nrao.edu>
Date: Mon, 22 Feb 2021 13:30:17 -0500
Subject: [PATCH] fix bug with queues dictionary access

---
 .gitignore                                               | 1 +
 .../workspaces/capability/services/capability_service.py | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/.gitignore b/.gitignore
index 6a0c89913..b0ef2dda4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -70,6 +70,7 @@ services/notification/notification.log
 **/coverage.xml
 **/coverage.json
 pyproject.toml
+package-lock.json
 
 # Ignore docker volume mount points
 services/**/**/apps
diff --git a/shared/workspaces/workspaces/capability/services/capability_service.py b/shared/workspaces/workspaces/capability/services/capability_service.py
index 988855393..7376be8e5 100644
--- a/shared/workspaces/workspaces/capability/services/capability_service.py
+++ b/shared/workspaces/workspaces/capability/services/capability_service.py
@@ -102,9 +102,10 @@ class CapabilityService(CapabilityServiceIF):
                 == CapabilityStepType.PrepareAndRunWorkflow
             ):
                 # Return capability engine to available state
-                self.queues[execution.capability.name].complete_execution(
-                    capability_event.execution_id
-                )
+                if self.queues:
+                    self.queues.get(execution.capability.name).complete_execution(
+                        capability_event.execution_id
+                    )
 
             if execution.current_step != len(step_sequence)-1:
                 # Execution is not on its last step
@@ -127,7 +128,7 @@ class CapabilityService(CapabilityServiceIF):
                 self.enqueue_execution(execution, ExecutionPriority.Default.value)
 
             # Update execution record's state
-            execution.state = ExecutionState.Ready.name
+            # execution.state = ExecutionState.Ready.name
             self.capability_info.save_execution(execution)
         else:
             # TODO: Logging
-- 
GitLab