How to use executor

    let rt = Builder::new().core_threads(1).build().unwrap();
    let m = Miner::new(cfg_loaded, rt.executor());

since rt.executor() has been changed
what we need to call?

do we need to manage it?

what the differences between



task::spawn(async move {})

It sounds like you are looking for the Handle type. The difference between handle.spawn(...) and tokio::spawn(...) is that tokio::spawn can only be used inside an async fn, whereas handle.spawn(...) can be used anywhere.

thread 'main' panicked at 'spawning not enabled for runtime', <::std::macros::panic macros>:2:4
but i meet with this error how can i solve it ....

You need to call either threaded_scheduler or basic_scheduler on your builder.

let rt = Builder::new().core_threads(1).build().unwrap();

what's role core_threads play in this?
to launch a single thread?

The core_threads argument doesn't do anything unless you turn on threaded_scheduler. The threaded scheduler uses a fixed number of threads, and core_threads can change the default number of threads.

thread 'tokio-runtime-worker' panicked at 'there is no timer running, must be called from the context of Tokio runtime', /home/cery/.cargo/registry/src/
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'Cannot start a runtime from within a runtime. This happens because a function (like `block_on`) attempted to block the current thread while the thread is being used to drive asynchronous tasks.', /home/cery/.cargo/registry/src/

i don't know where this is appear, can you tell me how to debug it?

The "there is no timer running, must be called from the context of Tokio runtime" means that you forgot to call .enable_all() on your builder.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.