-
I'm trying to replicate the following code in Rust: def step(self):
# get event from queue
...
callbacks = event.callbacks
for callback in callbacks:
callback(event) I have tried the following, however the fn step(&mut self, py: Python<'_>) -> PyResult<()> {
// Get entry from queue in self...
...
let event = entry.0.event.as_ref(py);
for cb in event.getattr("callbacks")?.iter()? {
cb?.call1((event,))?;
}
...
} I'm at a bit of a loss as to how to debug and/or fix this besides trying random combinations of |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
The issue was with the |
Beta Was this translation helpful? Give feedback.
The issue was with the
&mut self
. One of the callbacks was calling another method onself
(to insert into the event queue) which was resulting in the double borrow. I've replaced them withself_: &PyCell<Self>
and ensured there's no outstanding borrows when the callbacks are called