From e4cf40789c34dae36b10956fc45fe4510f8424fb Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sat, 19 Aug 2023 18:44:43 -0500 Subject: [PATCH] Dont try to resume dead threads in the scheduler --- src/lune/scheduler/impl_runner.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/lune/scheduler/impl_runner.rs b/src/lune/scheduler/impl_runner.rs index 0ed44a8..918cb6d 100644 --- a/src/lune/scheduler/impl_runner.rs +++ b/src/lune/scheduler/impl_runner.rs @@ -34,6 +34,12 @@ where let thread_id = thread.id(); let (thread, args) = thread.into_inner(self.lua); + // Make sure this thread is still resumable, it might have + // been resumed somewhere else or even have been cancelled + if thread.status() != LuaThreadStatus::Resumable { + continue; + } + // Resume the thread, ensuring that the schedulers // current thread id is set correctly for error catching self.state.set_current_thread_id(Some(thread_id));