chore(python): minor changes

This commit is contained in:
cschen 2024-08-17 23:48:02 +02:00
parent d6594928d9
commit 76e5320e6a
3 changed files with 6 additions and 5 deletions

View file

@ -10,7 +10,7 @@ use pyo3::prelude::*;
#[pymethods]
impl Client {
#[new]
fn pyconnect(host: String, username: String, password: String) -> crate::Result<Self> {
fn __new__(host: String, username: String, password: String) -> crate::Result<Self> {
super::tokio().block_on(async move { Client::new(host, username, password).await })
}

View file

@ -96,10 +96,10 @@ impl Cursor {
}
#[getter(user)]
fn pyuser(&self) -> String {
fn pyuser(&self) -> Option<String> {
match self.user {
Some(user) => user.to_string(),
None => "".to_string(),
Some(user) => Some(user.to_string()),
None => None,
}
}
}

View file

@ -25,7 +25,8 @@ fn tokio() -> &'static tokio::runtime::Runtime {
RT.get_or_init(|| tokio::runtime::Runtime::new().unwrap())
}
// workaround to allow the GIL to be released across awaits
// workaround to allow the GIL to be released across awaits, waiting on
// https://github.com/PyO3/pyo3/pull/3610
struct AllowThreads<F>(F);
impl<F> Future for AllowThreads<F>