-
Notifications
You must be signed in to change notification settings - Fork 607
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
Panic 'no Task is currently running' in compat03as01 AsyncRead #1463
Comments
im pretty sure compat03as01 futures need to run inside a futures 0.1 executor to actually work |
correct, currently the approach is to convert 0.1 futures into 0.3, write your code in 0.3 then convert the application future back into 0.1 to then pass it to a 0.1 executor. |
I see. Thanks for the clarification. It actually works fine for me to run the 0.3 application future in a It probably makes sense that the above example panics since it's calling After trying harder, I found out that this generally seems to work. Compat01As03 seems to provide a current 0.1 task to the underlying future, which makes sense. let fut01 = tokio::io::read(stream01, &mut buffer); // do something on a 0.1 async io, returns 0.1 future
let (_, buffer, res) = await!( Compat01As03::new(fut01) )?; // wrap to make it a 0.3 future and run it. works fine The weird thing is, that the same approach doesn't work with the websocket handshake: let ws_fut01 = tokio_tungstenite::accept_async(stream01); // creates a 0.1 future that does a websocket handshake on the given 0.1 async io
let ws = await!( Compat01As03::new(ws_fut01) )?; // panics with 'no Task is currently running' even though Compat01As03 should provide a current task? However, this now looks more like a problem with tokio-tungstenite. Or is there anything in particular that a 0.1 future or async io implementation could do wrong in a way that lets it work fine in a real executor but panic if wrapped in Compat01As03? |
I found out that I was mistaken by assuming that |
Wrapping a 0.3
AsyncRead+AsyncWrite
object using compat03as01 to make it 0.1AsyncRead+AsyncWrite
compatible seems to panic with "no Task is currently running" every time it's being read from or written to.I was actually trying to use a
romio::TcpListener
to accept connections and do a websocket handshake usingtokio_tungstenite::accept_async
, but here's a smaller example of the same problem:Versions:
Backtrace snippet:
Looks like Compat uses
Current::new
which in turn callstask01::current()
which panics because there's no current task. This problem looks similar to #1251.I couldn't get it to work (running in either LocalPool, ThreadPool or with executor::block_on, it always panics). I would expect that a current Task is provided automatically by the compat wrapper. Is this a bug or is there something special that needs to be done to provide a current task?
The text was updated successfully, but these errors were encountered: