Not expecting multiple simultaneous reads for a given frame

This commit is contained in:
Alan Justino
2020-05-11 11:56:56 -03:00
parent 6bef4b2943
commit b67d570dc8
2 changed files with 5 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
use std::fmt;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Mutex, RwLock};
use std::sync::Mutex;
use indexmap::IndexMap;
use itertools::Itertools;
@@ -93,7 +93,7 @@ pub struct Frame {
/// index of last instruction ran
pub lasti: AtomicUsize,
/// marker to know if this frame is being traced
pub trace: RwLock<PyObjectRef>,
pub trace: Mutex<PyObjectRef>,
state: Mutex<FrameState>,
}
@@ -169,7 +169,7 @@ impl Frame {
stack: Vec::new(),
blocks: Vec::new(),
}),
trace: RwLock::new(vm.get_none()),
trace: Mutex::new(vm.get_none()),
}
}
}

View File

@@ -71,13 +71,13 @@ impl FrameRef {
#[pyproperty]
fn f_trace(self) -> PyObjectRef {
let boxed = self.trace.read();
let boxed = self.trace.lock();
boxed.unwrap().clone()
}
#[pyproperty(setter)]
fn set_f_trace(self, value: PyObjectRef) {
let mut storage = self.trace.write().unwrap();
let mut storage = self.trace.lock().unwrap();
*storage = value;
}
}