-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coroutines can be started without being awaited #51
Comments
This has been brought up before, and I provided a workaround for it in that thread. At the time I dismissed it as a caveat for the library, but since multiple people have mentioned it as unexpected behaviour, I'm thinking it needs to be either clearly documented or potentially fixed in some fashion. Why the problem exists:Calling A simple workaround:The problem can be avoided by wrapping the futures written in from my_async_module import rust_sleep
async def py_sleep():
return await rust_sleep() The coroutine will do nothing when called. Instead, awaiting it the first time will call Potential Solutions:One obvious solution would be to incorporate the workaround into the Instead of incorporating it directly into the Alternatively we could delay the call to Problems with this solutionFixing this will only fix the first On the first public release, we called this conversion I'm a bit split on this issue, so I'd love to hear peoples thoughts on it. I think it's possible to fix, but the question I have is whether it should be documented, fully fixed, or have the workaround as a separate library function. |
Ah I hadn't considered that workaround, thank you. The solution that makes the most sense to me is incorporating the workaround into the Thanks for the incredibly detailed and informative reply! |
🐛 Bug Reports
Using the tokio example from the README, the coroutine can be started without awaiting it in python.
I apologise if this is documented somewhere or if this has an obvious solution in rust, I am very new to rust.
🌍 Environment
rustc --version
): rustc 1.55.0 (c8dfcfe04 2021-09-06)version = "0.x.y"
withgit = "https://github.com/awestlake87/pyo3-asyncio")?
: Yes, with the same results💥 Reproducing
Outputs:
It should be noted that if the
await asyncio.sleep(1)
is removed, nothing is output, this is different behaviour than standard python coroutines which would output a warning:Built using maturin.
The text was updated successfully, but these errors were encountered: