Skip to content

Commit 0ac4615

Browse files
authored
fix: fix scout deadlock (#188)
Releasing GIL in Scout destructor prevents the deadlock.
1 parent c689935 commit 0ac4615

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/session.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ impl _PullSubscriber {
296296
}
297297

298298
#[pyclass(subclass)]
299-
pub struct _Scout(Scout<()>);
299+
pub struct _Scout(Option<Scout<()>>);
300300

301301
#[pyfunction]
302302
pub fn scout(
@@ -315,7 +315,13 @@ pub fn scout(
315315
let config = config.and_then(|c| c.0.clone().take()).unwrap_or_default();
316316
let scout = zenoh::scout(what, config).with(callback).res_sync();
317317
match scout {
318-
Ok(scout) => Ok(_Scout(scout)),
318+
Ok(scout) => Ok(_Scout(Some(scout))),
319319
Err(e) => Err(e.to_pyerr()),
320320
}
321321
}
322+
323+
impl Drop for _Scout {
324+
fn drop(&mut self) {
325+
Python::with_gil(|gil| gil.allow_threads(|| drop(self.0.take())));
326+
}
327+
}

0 commit comments

Comments
 (0)