Skip to content

Commit 526d0ab

Browse files
authored
Merge pull request #7 from bitcraze/rik/wait_disconnect
Add wait_disconnect method to Crazyflie class for graceful disconnection
2 parents b2948b7 + 9829365 commit 526d0ab

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

cflib2/_rust.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,12 @@ class Crazyflie:
324324
r"""
325325
Disconnect from the Crazyflie
326326
"""
327+
async def wait_disconnect(self) -> builtins.str:
328+
r"""
329+
Wait for the Crazyflie to be disconnected
330+
331+
Returns a human-readable string describing the reason for disconnection.
332+
"""
327333
def commander(self) -> Commander:
328334
r"""
329335
Get the commander subsystem

rust/src/crazyflie.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,18 @@ impl Crazyflie {
134134
})
135135
}
136136

137+
/// Wait for the Crazyflie to be disconnected
138+
///
139+
/// Returns a human-readable string describing the reason for disconnection.
140+
#[gen_stub(override_return_type(type_repr = "collections.abc.Coroutine[typing.Any, typing.Any, builtins.str]"))]
141+
fn wait_disconnect<'py>(&self, py: Python<'py>) -> PyResult<Bound<'py, PyAny>> {
142+
let inner = self.inner.clone();
143+
pyo3_async_runtimes::tokio::future_into_py(py, async move {
144+
let reason = inner.wait_disconnect().await;
145+
Ok(reason)
146+
})
147+
}
148+
137149
/// Get the commander subsystem
138150
fn commander(&self) -> Commander {
139151
Commander {

0 commit comments

Comments
 (0)