Issues with async support / Tokio
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
I attempt to compile the following code with experimental-async feature enabled:
#[pyclass]
struct Sender {
_inner: IPCSender
}
#[pymethods]
impl Sender {
#[new]
async fn new(printname: String) -> PyResult<Self> {
let ipcsender = IPCSender::new(&printname).await?;
Ok(Self { _inner: ipcsender })
}
}
#[pymodule]
fn python_ipc(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
m.add_class::<Sender>()?;
Ok(())
}
However, I get this error message:
error[E0599]: no method named `convert` found for opaque type `impl Future<Output = Result<Sender, PyErr>>` in the current scope
--> src/lib.rs:11:1
|
11 | #[pymethods]
| ^^^^^^^^^^^^ method not found in `impl Future<Output = Result<Sender, PyErr>>`
|
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
I tried adding:
static RT: OnceLock<tokio::runtime::Runtime> = OnceLock::new();
RT.get_or_init(|| tokio::runtime::Runtime::new().expect("Unable to start Tokio runtime"));
to python_ipc function, but it still doesn't work.
IPCSender is a struct from a local crate, which uses tokio runtime.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the report from src/lib.rs with the experimental-async feature and the async #[new] method shown. Start by inspecting how the #[pymethods] macro handles async constructors and compare that with async methods. Done means establishing whether this constructor pattern is supported and resolving or documenting the limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100