fix: python binding build
@@ -10,9 +10,11 @@ impl Client {
fn subscribe_topic(&mut self, topic: &str, callback: PyObject) -> PyResult<()> {
self.subscribe_topics([topic].to_vec(), callback)
}
+
fn subscribe_topics(&mut self, topics: Vec<&str>, callback: PyObject) -> PyResult<()> {
- let result = self
- .client
+ let rt = tokio::runtime::Runtime::new()?;
+ let result = rt.block_on(
+ self.client
.subscriber()
.with_topics(topics.iter().map(|&topic| topic.try_into().unwrap()).collect())
.subscribe(move |event| {
@@ -24,21 +26,26 @@ impl Client {
PyErr::new::<exceptions::PyTypeError, _>("Unable to use the python callback function!")
.to_object(py)
});
- });
+ }),
+ );
match result {
Err(err) => Err(PyErr::new::<exceptions::PyTypeError, _>(err.to_string())),
Ok(()) => Ok(()),
}
}
+
fn unsubscribe(&mut self) -> PyResult<()> {
- let result = self.client.subscriber().unsubscribe();
+ let rt = tokio::runtime::Runtime::new()?;
+ let result = rt.block_on(self.client.subscriber().unsubscribe());
match result {
Err(err) => Err(PyErr::new::<exceptions::PyTypeError, _>(err.to_string())),
Ok(()) => Ok(()),
}
}
+
fn disconnect(&mut self) -> PyResult<()> {
- let result = self.client.subscriber().disconnect();
+ let rt = tokio::runtime::Runtime::new()?;
+ let result = rt.block_on(self.client.subscriber().disconnect());
match result {
Err(err) => Err(PyErr::new::<exceptions::PyTypeError, _>(err.to_string())),
Ok(()) => Ok(()),
