From 9b61adc375ac0c12bb68b3c5515abaa0d667a2ac Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 2 Jul 2023 11:26:58 -0600 Subject: [PATCH] Added check to allow restored threads to be run in RunThread --- thread.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/thread.go b/thread.go index 5759f4b..b9df6e4 100644 --- a/thread.go +++ b/thread.go @@ -367,7 +367,16 @@ func RunThread(ctx * GraphContext, thread Thread) error { ctx.Log.Logf("thread", "THREAD_RUN: %s", thread.ID()) err := UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap) (error) { - return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) + thread_state := thread.State().(ThreadState) + owner_id := NodeID("") + if thread_state.Owner() != nil { + owner_id = thread_state.Owner().ID() + } + // Don't lock the thread if it's already locked itself + if owner_id != thread.ID() { + return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) + } + return nil }) if err != nil { return err