Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl _PullSubscriber {
}

#[pyclass(subclass)]
pub struct _Scout(Scout<()>);
pub struct _Scout(Option<Scout<()>>);

#[pyfunction]
pub fn scout(
Expand All @@ -315,7 +315,13 @@ pub fn scout(
let config = config.and_then(|c| c.0.clone().take()).unwrap_or_default();
let scout = zenoh::scout(what, config).with(callback).res_sync();
match scout {
Ok(scout) => Ok(_Scout(scout)),
Ok(scout) => Ok(_Scout(Some(scout))),
Err(e) => Err(e.to_pyerr()),
}
}

impl Drop for _Scout {
fn drop(&mut self) {
Python::with_gil(|gil| gil.allow_threads(|| drop(self.0.take())));
}
}