diff --git a/lib/galaxy/workflow/scheduling_manager.py b/lib/galaxy/workflow/scheduling_manager.py index 5b6d1ee52dd..9c30615adc5 100644 --- a/lib/galaxy/workflow/scheduling_manager.py +++ b/lib/galaxy/workflow/scheduling_manager.py @@ -202,10 +202,10 @@ class WorkflowRequestMonitor(object): sa_session = self.app.model.context workflow_invocation = sa_session.query(model.WorkflowInvocation).get(invocation_id) - if not workflow_invocation or not workflow_invocation.active: - return False - try: + if not workflow_invocation or not workflow_invocation.active: + return False + # This ensures we're only ever working on the 'first' active # workflow invocation in a given history, to force sequential # activation. @@ -218,6 +218,8 @@ class WorkflowRequestMonitor(object): # TODO: eventually fail this - or fail it right away? log.exception("Exception raised while attempting to schedule workflow request.") return False + finally: + sa_session.expunge_all() # A workflow was obtained and scheduled... return True