Skip to content

Commit

Permalink
Fix data loss issue by ensuring proper locking and clearing of changes (
Browse files Browse the repository at this point in the history
  • Loading branch information
koseki2580 authored Jan 10, 2025
1 parent 8d89bde commit fa1c853
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,16 +328,14 @@ impl RustNotify {
}
}
}
let py_changes = slf
.borrow()
.changes
.lock()
.unwrap()
.to_owned()
.into_pyobject(py)?
.into_any()
.unbind();
slf.borrow().clear();
let py_changes = {
let borrowed = slf.borrow();
let mut locked_changes = borrowed.changes.lock().unwrap();
let py_changes = locked_changes.to_owned().into_pyobject(py)?.into_any().unbind();
// Clear the changes while holding the lock
locked_changes.clear();
py_changes
};
Ok(py_changes)
}

Expand Down

0 comments on commit fa1c853

Please sign in to comment.