Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions crates/taskito-core/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,13 @@ pub trait WorkerDispatcher: Send + Sync {

/// Signal the pool to stop accepting new work.
fn shutdown(&self);

/// Notify the pool that a running job should be cancelled.
///
/// Pools that run tasks in-process (e.g. the thread pool) can rely on the
/// storage cancel flag and provide a no-op. Pools that execute tasks in a
/// separate process (e.g. the prefork pool) must use this hook to deliver
/// a side-channel signal so the worker observes the cancel without polling
/// storage.
fn notify_cancel(&self, _job_id: &str) {}
}
9 changes: 9 additions & 0 deletions crates/taskito-python/src/prefork/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ impl ChildWriter {
pub fn send_shutdown(&mut self) {
let _ = self.send(&ParentMessage::Shutdown);
}

/// Send a cooperative-cancel request for `job_id`. Returns the underlying
/// I/O error if the pipe is broken so the caller can decide whether to
/// retry or drop the request.
pub fn send_cancel(&mut self, job_id: &str) -> std::io::Result<()> {
self.send(&ParentMessage::Cancel {
job_id: job_id.to_string(),
})
}
}

/// Reader half — reads result messages from the child process via stdout.
Expand Down
Loading
Loading