Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions crates/sdk-core/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ impl Worker {
///
/// You can then wait on `shutdown` or [Worker::finalize_shutdown].
pub fn initiate_shutdown(&self) {
let mut shutdown_rpc_handle = self.shutdown_rpc_handle.lock();
if !self.shutdown_token.is_cancelled() {
info!(
task_queue=%self.config.task_queue,
Expand Down Expand Up @@ -1419,10 +1420,7 @@ impl Worker {
}
}

// Spawn the ShutdownWorker RPC so the server can complete in-flight polls.
// The handle is stored and awaited in shutdown() to ensure completion.
let mut guard = self.shutdown_rpc_handle.lock();
if guard.is_some() || already_initiated_shutdown {
if shutdown_rpc_handle.is_some() || already_initiated_shutdown {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this short circuit be move up just under the lock acquisition so that other callers do not do the same checks and logging?

return;
}

Expand Down Expand Up @@ -1458,7 +1456,7 @@ impl Worker {
_ => {}
}
});
*guard = Some(handle);
*shutdown_rpc_handle = Some(handle);
}

/// Unique identifier for this worker instance.
Expand Down
Loading