Tokio: Can't install tokio async await ( LocalWaker )

Created on 20 Feb 2019  ยท  7Comments  ยท  Source: tokio-rs/tokio

Version

Following this page and from a new cargo init :
https://github.com/tokio-rs/tokio/tree/master/tokio-async-await

testing_tokio v0.1.0 (/root/testing_tokio)
โ””โ”€โ”€ tokio v0.1.15
โ”œโ”€โ”€ tokio-async-await v0.1.5
โ”‚ โ””โ”€โ”€ tokio-io v0.1.11
โ”œโ”€โ”€ tokio-codec v0.1.1
โ”‚ โ””โ”€โ”€ tokio-io v0.1.11 ()
โ”œโ”€โ”€ tokio-current-thread v0.1.4
โ”‚ โ””โ”€โ”€ tokio-executor v0.1.6
โ”œโ”€โ”€ tokio-executor v0.1.6 (
)
โ”œโ”€โ”€ tokio-fs v0.1.5
โ”‚ โ”œโ”€โ”€ tokio-io v0.1.11 ()
โ”‚ โ””โ”€โ”€ tokio-threadpool v0.1.11
โ”‚ โ””โ”€โ”€ tokio-executor v0.1.6 (
)
โ”‚ โ””โ”€โ”€ tokio-io v0.1.11 ()
โ”œโ”€โ”€ tokio-io v0.1.11 (
)
โ”œโ”€โ”€ tokio-reactor v0.1.8
โ”‚ โ”œโ”€โ”€ tokio-executor v0.1.6 ()
โ”‚ โ””โ”€โ”€ tokio-io v0.1.11 (
)
โ”œโ”€โ”€ tokio-sync v0.1.1
โ”œโ”€โ”€ tokio-tcp v0.1.3
โ”‚ โ”œโ”€โ”€ tokio-io v0.1.11 ()
โ”‚ โ””โ”€โ”€ tokio-reactor v0.1.8 (
)
โ”œโ”€โ”€ tokio-threadpool v0.1.11 ()
โ”œโ”€โ”€ tokio-timer v0.2.10
โ”‚ โ””โ”€โ”€ tokio-executor v0.1.6 (
)
โ”œโ”€โ”€ tokio-udp v0.1.3
โ”‚ โ”œโ”€โ”€ tokio-codec v0.1.1 ()
โ”‚ โ”œโ”€โ”€ tokio-io v0.1.11 (
)
โ”‚ โ””โ”€โ”€ tokio-reactor v0.1.8 ()
โ””โ”€โ”€ tokio-uds v0.2.5
โ”œโ”€โ”€ tokio-codec v0.1.1 (
)
โ”œโ”€โ”€ tokio-io v0.1.11 ()
โ””โ”€โ”€ tokio-reactor v0.1.8 (
)

Platform

Linux 4.13.0-kali1-amd64 #1 SMP Debian 4.13.10-1kali2 (2017-11-08) x86_64 GNU/Linux

Description

I am simply following the exemple. Nothing more. And I have the following issue during the build :

Compiling tokio-async-await v0.1.5 error[E0432]: unresolved importstd::task::LocalWaker --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-async-await-0.1.5/src/compat/forward.rs:7:17 | 7 | use std::task::{LocalWaker, Poll as StdPoll}; | ^^^^^^^^^^ noLocalWakerintask
Seems to be relate with Future issue about LocalWaker ...
Thank you.

Most helpful comment

The workaround will be to use an older nightly. We'll need to discuss with tokio-rs members as to what to do (reimplement with the newer API (https://github.com/aturon/rfcs/blob/future/text/0000-futures.md#rationale-drawbacks-and-alternatives-to-the-wakeup-design-waker?), or some other fix).

All 7 comments

Exact so I presume Async Await is dead for the moment ? Do you have a work around ?

The workaround will be to use an older nightly. We'll need to discuss with tokio-rs members as to what to do (reimplement with the newer API (https://github.com/aturon/rfcs/blob/future/text/0000-futures.md#rationale-drawbacks-and-alternatives-to-the-wakeup-design-waker?), or some other fix).

Using an older nightly breaks other crates. As a work around you can do this:

[dependencies]
futures-preview = { version = "0.3.0-alpha.13", features = ["compat"] }
tokio = "*"
#![features(async_await, await_macro, futures_api)]
use futures::future::FutureObj;
use futures::prelude::*;

fn main() {
  tokio::run(FutureObj::new(Box::new(async move {
    println!("running");
    tokio::spawn(FutureObj::new(Box::new(async move {
       println!("spawned");
       Ok(())
    })).compat());
    Ok(())
  })).compat());
}

Thank you David for the work around. The issue is I can't even build. Do you have a specific .toml according to it ?

@taiki-e seems to be the Real MVP here. I hope your PR will be accepted !

Thanks everyone for your help in this issue.

@victordetarragon tokio-async-await provides a tokio::run_async and tokio::spawn_async which take v3 Futures. By using the compat traits from futures-preview you can roll your own until it builds again. I updated the comment with a Cargo.toml and verified that the code example runs as is.

If you are returning futures from trait functions you need to wrap them in FutureObj<Box<F: Future>> anyway, so you most likely already have FutureObj<Box<F: Future>> anyway. All that is missing is calling compat()

Pushed out a release w/ the fix. Thanks @taiki-e

Was this page helpful?
0 / 5 - 0 ratings