mirror of
https://github.com/google/bumble.git
synced 2026-05-24 06:25:32 +00:00
Add python async wrapper, move hci non-wrapper to internal, add hci::internal tests
This commit is contained in:
@@ -22,11 +22,13 @@
|
||||
|
||||
// Re-exported to make it easy for users to depend on the same `PyObject`, etc
|
||||
pub use pyo3;
|
||||
pub use pyo3_asyncio;
|
||||
|
||||
use pyo3::{
|
||||
intern,
|
||||
prelude::*,
|
||||
types::{PyDict, PyTuple},
|
||||
};
|
||||
pub use pyo3_asyncio;
|
||||
|
||||
pub mod assigned_numbers;
|
||||
pub mod common;
|
||||
@@ -122,3 +124,11 @@ impl ClosureCallback {
|
||||
(self.callback)(py, args, kwargs).map(|_| py.None())
|
||||
}
|
||||
}
|
||||
|
||||
/// Wraps the Python function in a Python async function. `pyo3_asyncio` needs functions to be
|
||||
/// marked async to properly inject a running loop.
|
||||
pub(crate) fn wrap_python_async<'a>(py: Python<'a>, function: &'a PyAny) -> PyResult<&'a PyAny> {
|
||||
PyModule::import(py, intern!(py, "bumble.utils"))?
|
||||
.getattr(intern!(py, "wrap_async"))?
|
||||
.call1((function,))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user