Added check to allow restored threads to be run in RunThread

graph-rework-2
noah metz 2023-07-02 11:26:58 -06:00
parent 06a6b0f09a
commit 9b61adc375
1 changed files with 10 additions and 1 deletions

@ -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