You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So with the latest tokio integrated (#25) now it won't allow to spawn another tokio reactor when netsim is running. So smth like this is not possible:
use futures::future;
use netsim::{Network, node, Ipv4Range};
use tokio::runtime::current_thread::Runtime;
use unwrap::unwrap;
fn main() {
let network = Network::new();
let network_handle = network.handle();
let node1 = node::ipv4::machine(move |ip| {
println!("node1: {}", ip);
let fut = future::ok::<_, ()>(());
let mut evloop = unwrap!(Runtime::new());
unwrap!(evloop.block_on(fut));
future::ok(())
});
let fut = future::lazy(move || {
let (spawn_complete, _ip_plug) = network_handle.spawn_ipv4_tree(Ipv4Range::global(), node1);
spawn_complete
});
let mut evloop = unwrap!(Runtime::new());
unwrap!(evloop.block_on(fut));
}
and results with an error:
thread '<unnamed>' panicked at 'Multiple executors at once: EnterError { reason: "attempted to run an executor while another executor is already running" }', src/libcore/result.rs:997:5
In most cases when we have futures code this should not be a problem. Although, I can see 2 cases where it will be:
when we have a piece of code that internally runs tokio reactor;
when we have futures that do not implement Send trait.
The first thing we could do here is at least document the situation.
Another thing to consider is to provide a netsim machine node that runs on a forked process instead of a thread.
The text was updated successfully, but these errors were encountered:
So with the latest tokio integrated (#25) now it won't allow to spawn another tokio reactor when netsim is running. So smth like this is not possible:
and results with an error:
In most cases when we have futures code this should not be a problem. Although, I can see 2 cases where it will be:
Send
trait.The first thing we could do here is at least document the situation.
Another thing to consider is to provide a netsim
machine
node that runs on a forked process instead of a thread.The text was updated successfully, but these errors were encountered: