Skip to content

Commit

Permalink
add ability to close/stop scheduler and executor
Browse files Browse the repository at this point in the history
  • Loading branch information
milenkovicm committed Dec 8, 2024
1 parent ab38e6a commit 2766e18
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/examples/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@
executor.wait_for_termination()
# %%
# %%
executor.close()
# %%
1 change: 1 addition & 0 deletions python/examples/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@
# %%
scheduler.wait_for_termination()
# %%
scheduler.close()
25 changes: 25 additions & 0 deletions python/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ impl PyScheduler {
None => Ok(()),
}
}

pub fn close(&mut self) -> PyResult<()> {
let mut handle = None;
std::mem::swap(&mut self.handle, &mut handle);

match handle {
Some(handle) => handle.abort(),
None => {}
};

Ok(())
}

#[classattr]
pub fn version() -> &'static str {
ballista_core::BALLISTA_VERSION
Expand Down Expand Up @@ -199,6 +212,18 @@ impl PyExecutor {
}
}

pub fn close(&mut self) -> PyResult<()> {
let mut handle = None;
std::mem::swap(&mut self.handle, &mut handle);

match handle {
Some(handle) => handle.abort(),
None => {}
};

Ok(())
}

#[classattr]
pub fn version() -> &'static str {
ballista_core::BALLISTA_VERSION
Expand Down

0 comments on commit 2766e18

Please sign in to comment.