mirror of
https://github.com/hexedtech/codemp.git
synced 2024-11-22 23:34:49 +01:00
chore(python): minor changes
This commit is contained in:
parent
d6594928d9
commit
76e5320e6a
3 changed files with 6 additions and 5 deletions
|
@ -10,7 +10,7 @@ use pyo3::prelude::*;
|
||||||
#[pymethods]
|
#[pymethods]
|
||||||
impl Client {
|
impl Client {
|
||||||
#[new]
|
#[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 })
|
super::tokio().block_on(async move { Client::new(host, username, password).await })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,10 +96,10 @@ impl Cursor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[getter(user)]
|
#[getter(user)]
|
||||||
fn pyuser(&self) -> String {
|
fn pyuser(&self) -> Option<String> {
|
||||||
match self.user {
|
match self.user {
|
||||||
Some(user) => user.to_string(),
|
Some(user) => Some(user.to_string()),
|
||||||
None => "".to_string(),
|
None => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ fn tokio() -> &'static tokio::runtime::Runtime {
|
||||||
RT.get_or_init(|| tokio::runtime::Runtime::new().unwrap())
|
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);
|
struct AllowThreads<F>(F);
|
||||||
|
|
||||||
impl<F> Future for AllowThreads<F>
|
impl<F> Future for AllowThreads<F>
|
||||||
|
|
Loading…
Reference in a new issue