Problem Description
When running workflows in --exclusive mode, RushTI holds connections to all TM1 instances for the entire duration of the workflow, even if an instance's tasks finish early.
Example: A workflow with 100 tasks connects to TM1_Instance_A for the first 5 tasks (~10 seconds) and TM1_Instance_B for the remaining 95 tasks (~30 minutes). The current implementation holds the exclusive session on TM1_Instance_A for 30 minutes and 10 seconds, blocking other RushTI instances from using TM1_Instance_A — even though its work completed in 10 seconds.
This applies to both exclusive and non-exclusive modes: idle sessions consume server resources unnecessarily.
Proposed Solution
Implement early session release in the DAG execution loop (work_through_tasks_dag). After each task completes, check whether there are any remaining tasks (pending or running) for the same TM1 instance. If none remain, immediately logout from that instance.
Implementation approach:
- Build a per-instance task counter at workflow start from all tasks in the DAG
- Decrement the counter when a task completes
- When an instance's counter reaches 0, call
logout() on that instance's TM1Service, log the early release, and remove it from the active services dict
- Respect
tm1_preserve_connections and force logic (exclusive mode force-closes preserved connections)
- Skip early release for instances that still have pending/running tasks
Benefits:
- Reduces exclusive mode blocking time significantly for multi-instance workflows
- Frees TM1 server resources (session slots, memory) as early as possible
- No behavior change for single-instance workflows
Alternatives Considered
- No change (status quo): Sessions remain open until workflow ends. Simple but wasteful.
- Periodic session cleanup sweep: Check all instances periodically (e.g., every N tasks) instead of on every completion. Adds complexity without meaningful benefit since the per-completion check is O(1) with a counter.
Additional Context
The change is localized to execution.py (work_through_tasks_dag and logout) and the DAG class (adding a method to query remaining tasks per instance). The logout function already supports selective logout via tm1_preserve_connections and force parameters.
Problem Description
When running workflows in
--exclusivemode, RushTI holds connections to all TM1 instances for the entire duration of the workflow, even if an instance's tasks finish early.Example: A workflow with 100 tasks connects to TM1_Instance_A for the first 5 tasks (~10 seconds) and TM1_Instance_B for the remaining 95 tasks (~30 minutes). The current implementation holds the exclusive session on TM1_Instance_A for 30 minutes and 10 seconds, blocking other RushTI instances from using TM1_Instance_A — even though its work completed in 10 seconds.
This applies to both exclusive and non-exclusive modes: idle sessions consume server resources unnecessarily.
Proposed Solution
Implement early session release in the DAG execution loop (
work_through_tasks_dag). After each task completes, check whether there are any remaining tasks (pending or running) for the same TM1 instance. If none remain, immediately logout from that instance.Implementation approach:
logout()on that instance's TM1Service, log the early release, and remove it from the active services dicttm1_preserve_connectionsandforcelogic (exclusive mode force-closes preserved connections)Benefits:
Alternatives Considered
Additional Context
The change is localized to
execution.py(work_through_tasks_dagandlogout) and theDAGclass (adding a method to query remaining tasks per instance). Thelogoutfunction already supports selective logout viatm1_preserve_connectionsandforceparameters.