Closed sansyrox closed 2 years ago
Looking at your codebase, with normal requests, you scope the coroutine locally with the event loop object (see src/server.rs:143~145), however, you're not doing that with the corresponding websocket object(s), so you have to pass around the event loop there to then scope the coroutine future with.
Sorry for the delay! @ShadowJonathan is right, you'll probably have to pass the event loop reference through start_web_socket
to MyWs
, then pass it to pyo3_asyncio::into_future_with_loop
when converting your message handler coroutine here
Thank you @ShadowJonathan @awestlake87 :D
Passing the event loop(https://github.com/sansyrox/robyn/pull/134/files#diff-0d0da7574dadb5452e2f359138c914a901f38425138f1c2facc37f403b98ab7fR136) worked for me. :D
π Bug Reports
Hi,
I was trying to run a Python async function in the actix web sockets in Robyn.
I am trying to execute an async function but it is telling me that the event loop is not running. But I am pretty sure that the event loop is running as the other async functions are being executed in the HTTP routers.
Below is my implementation
But I am getting the following error:
π Environment
rustc --version
): rustc 1.52.1version = "0.x.y"
withgit = "https://github.com/awestlake87/pyo3-asyncio")?
: I am using "0.14.0"π₯ Reproducing
Please provide a minimal working example. This means both the Rust code and the Python.
Please also write what exact flags are required to reproduce your results.
Here is the PR that I created: https://github.com/sansyrox/robyn/pull/134
maturin develop
is the command to run it.