Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverting to previous state when hot-reloaded on_event failed #389

Closed
wants to merge 1 commit into from
Closed
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: 5 additions & 4 deletions binaries/runtime/src/operator/python.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ pub fn run(
}
};

let mut reload = false;
let mut previous_operator = None;
let reason = loop {
#[allow(unused_mut)]
let Ok(mut event) = incoming_events.recv() else { break StopReason::InputsClosed };

if let Event::Reload { .. } = event {
reload = true;
previous_operator = Some(operator.clone());
// Reloading method
match Python::with_gil(|py| -> Result<Py<PyAny>> {
// Saving current state
Expand Down Expand Up @@ -227,9 +227,10 @@ pub fn run(
.wrap_err("on_event has invalid return value")
}
Err(err) => {
if reload {
if let Some(prev_operator) = previous_operator.clone() {
// Allow error in hot reloading environment to help development.
warn!("{err}");
warn!("Reloaded Operator Failed with: {err}. Reverting to previous operator");
operator = prev_operator;
Ok(DoraStatus::Continue as i32)
} else {
Err(err)
Expand Down
Loading