Skip to content
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

Switch over to tokio-0.2 (and drop preview versions of futures?) #160

Closed
osa1 opened this issue Nov 27, 2019 · 10 comments · Fixed by #161
Closed

Switch over to tokio-0.2 (and drop preview versions of futures?) #160

osa1 opened this issue Nov 27, 2019 · 10 comments · Fixed by #161

Comments

@osa1
Copy link
Owner

osa1 commented Nov 27, 2019

I think tokio-0.2.1 supports features we need so we should switch over to it and drop the git versions. That should make development easier as we'll be able to use the documentation on crates.io etc. Similarly we should also drop futures-preview and futures-utils-preview and use futures and futures-utils.

@osa1
Copy link
Owner Author

osa1 commented Nov 28, 2019

Currently blocked on tokio-rs/tokio#1848 . There are workarounds but it seems easier to fix tokio first.

@osa1 osa1 changed the title Switch over to tokio-0.2.1 (and drop preview versions of futures?) Switch over to tokio-0.2 (and drop preview versions of futures?) Dec 3, 2019
@osa1
Copy link
Owner Author

osa1 commented Dec 3, 2019

WIP at branch tokio-0.2.2. Currently echo bot example fails with "no current reactor". No idea why and no idea how to debug ...

@FreeFull
Copy link

FreeFull commented Dec 3, 2019

Looking at Cargo.lock, it seems like some parts are still depending on the 0.2.0-alpha6 version of the tokio crates. The 0.2.0-alpha6 executor isn't compatible with the 0.2.2 executor.
Edit: And it's also a good idea to go from futures-preview to futures everywhere. For tokio, you'll probably want to enable the "stream" feature, so the relevant types from tokio implement the Stream trait from futures

@osa1
Copy link
Owner Author

osa1 commented Dec 4, 2019

That should not be a problem, the example I'm trying is libtiny_client's echo, and none of the library or the example uses the crates that use the old tokio (e.g. libtiny_tui).

@osa1
Copy link
Owner Author

osa1 commented Dec 4, 2019

Backtrace shows that the error happens in LocalSet::block_on:

Backtrace
   0:     0x55f2302c5704 - backtrace::backtrace::libunwind::trace::h1702f02e9561de90
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
   1:     0x55f2302c5704 - backtrace::backtrace::trace_unsynchronized::h1c634812fc0220cb
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
   2:     0x55f2302c5704 - std::sys_common::backtrace::_print_fmt::h9d5a053d21e8c033
                               at src/libstd/sys_common/backtrace.rs:84
   3:     0x55f2302c5704 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc65c735014fa52d2
                               at src/libstd/sys_common/backtrace.rs:61
   4:     0x55f2302e074c - core::fmt::write::h125da652425b39e8
                               at src/libcore/fmt/mod.rs:1030
   5:     0x55f2302c1f37 - std::io::Write::write_fmt::h20322e8675759303
                               at src/libstd/io/mod.rs:1412
   6:     0x55f2302c786e - std::sys_common::backtrace::_print::h56bfd19cdffe3007
                               at src/libstd/sys_common/backtrace.rs:65
   7:     0x55f2302c786e - std::sys_common::backtrace::print::h76b7a0cb6d897cab
                               at src/libstd/sys_common/backtrace.rs:50
   8:     0x55f2302c786e - std::panicking::default_hook::{{closure}}::h7cd2878d4328ecd0
                               at src/libstd/panicking.rs:188
   9:     0x55f2302c7561 - std::panicking::default_hook::hf3eaa2d2726e3f01
                               at src/libstd/panicking.rs:205
  10:     0x55f2302c7f6b - std::panicking::rust_panic_with_hook::h5240f420a7eb117e
                               at src/libstd/panicking.rs:464
  11:     0x55f2302b9017 - std::panicking::begin_panic::h30378294cff78edd
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:400
  12:     0x55f230213120 - tokio::io::driver::Handle::current::{{closure}}::hbe64b46f13530d20
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/io/driver/mod.rs:243
  13:     0x55f2301f9785 - std::thread::local::LocalKey<T>::try_with::h721d2a2b089a0eb7
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:262
  14:     0x55f2301f8754 - std::thread::local::LocalKey<T>::with::hdb3bee86b023f05d
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:239
  15:     0x55f23021307e - tokio::io::driver::Handle::current::hb99c070cd423bee8
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/io/driver/mod.rs:241
  16:     0x55f23022c897 - tokio::io::registration::Registration::new::hf15502be3c34632a
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/io/registration.rs:60
  17:     0x55f230242d62 - tokio::io::poll_evented::PollEvented<E>::new::hc572b3495c6640ce
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/io/poll_evented.rs:170
  18:     0x55f23022dc44 - tokio::net::tcp::stream::TcpStream::new::h9abb35c8dd3d75bc
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/net/tcp/stream.rs:118
  19:     0x55f230143fac - tokio::net::tcp::stream::TcpStream::connect_addr::{{closure}}::hecd22c1f36dbb829
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/net/tcp/stream.rs:100
  20:     0x55f23017db1d - <std::future::GenFuture<T> as core::future::future::Future>::poll::h9d3de66f1486eeba
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:44
  21:     0x55f23017b330 - std::future::poll_with_tls_context::h1c6e77693d72a424
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:100
  22:     0x55f230144a58 - tokio::net::tcp::stream::TcpStream::connect::{{closure}}::h458795f5ffd8142b
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/net/tcp/stream.rs:83
  23:     0x55f23017cc5d - <std::future::GenFuture<T> as core::future::future::Future>::poll::h311c1a77015eabbd
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:44
  24:     0x55f23017bf60 - std::future::poll_with_tls_context::hcdc78ccd1f64da31
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:100
  25:     0x55f23019e9f9 - libtiny_client::stream::Stream::new_tcp::{{closure}}::hdb9e4503b151e211
                               at libtiny_client/src/stream.rs:38
  26:     0x55f23017e1dd - <std::future::GenFuture<T> as core::future::future::Future>::poll::hfb54ab47e2ec81cf
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:44
  27:     0x55f23017bb00 - std::future::poll_with_tls_context::h93e648e515be56ec
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:100
  28:     0x55f230168745 - libtiny_client::try_connect::{{closure}}::h5c01e03f3587abde
                               at libtiny_client/src/lib.rs:651
  29:     0x55f23017de7d - <std::future::GenFuture<T> as core::future::future::Future>::poll::hd10453ed4e6d0d25
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:44
  30:     0x55f23017b780 - std::future::poll_with_tls_context::h7fa76276e2df0460
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:100
  31:     0x55f230161a6e - libtiny_client::main_loop::{{closure}}::hed215516e2bdda3d
                               at libtiny_client/src/lib.rs:407
  32:     0x55f23017e08f - <std::future::GenFuture<T> as core::future::future::Future>::poll::hf53a3d17baed1840
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/future.rs:44
  33:     0x55f230191bd8 - tokio::task::core::Core<T>::poll::h36ed9b16c5f3991e
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/core.rs:128
  34:     0x55f230155d78 - tokio::task::harness::Harness<T,S>::poll::{{closure}}::{{closure}}::he177f8c74cc5215c
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:120
  35:     0x55f230169d0c - core::ops::function::FnOnce::call_once::h8b0d726c155d9aec
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libcore/ops/function.rs:223
  36:     0x55f23019659e - <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h8723755a8839effd
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:316
  37:     0x55f2301a1945 - std::panicking::try::do_call::hb6d59f6e5c2ba242
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:287
  38:     0x55f2302cb2ba - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:81
  39:     0x55f2301a0677 - std::panicking::try::h1c546c9a1ce54c4d
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panicking.rs:265
  40:     0x55f230196825 - std::panic::catch_unwind::hbb05365d1bbd8403
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/panic.rs:395
  41:     0x55f230155af3 - tokio::task::harness::Harness<T,S>::poll::{{closure}}::h91fc172d7fe846f2
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:101
  42:     0x55f230134d8f - tokio::loom::std::causal_cell::CausalCell<T>::with_mut::h774c792e8b9bdac0
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/loom/std/causal_cell.rs:41
  43:     0x55f230154104 - tokio::task::harness::Harness<T,S>::poll::h561aa5fc20f8545b
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/harness.rs:100
  44:     0x55f2301a2298 - tokio::task::raw::poll::h1f746c9580be18bc
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/raw.rs:162
  45:     0x55f2301ed977 - tokio::task::raw::RawTask::poll::h1e36497afba82c79
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/raw.rs:113
  46:     0x55f23025f6fc - tokio::task::Task<S>::run::haf8367af4a56d392
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/mod.rs:370
  47:     0x55f2301f6a35 - tokio::task::local::Scheduler::tick::hfcfd1b98aa80b7ff
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:457
  48:     0x55f230122864 - <tokio::task::local::LocalFuture<F> as core::future::future::Future>::poll::hc305f7177b0c437d
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:333
  49:     0x55f23011fc45 - tokio::runtime::shell::Shell::block_on::h3848eae2094d15f5
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/shell.rs:47
  50:     0x55f230124708 - tokio::runtime::Runtime::block_on::{{closure}}::h566c7ba475dc42c3
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/mod.rs:407
  51:     0x55f23011f625 - tokio::runtime::spawner::Spawner::enter::h2b648be0e6754cc3
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/spawner.rs:28
  52:     0x55f230124e6a - tokio::runtime::handle::Handle::enter::{{closure}}::{{closure}}::he360b5c61a4efa98
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/handle.rs:36
  53:     0x55f23011eb1e - tokio::time::clock::Clock::enter::hdf892cdf316cc60a
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/time/clock.rs:30
  54:     0x55f23012489b - tokio::runtime::time::variant::with_default::h758b98c659b4be46
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/time.rs:43
  55:     0x55f230124d96 - tokio::runtime::handle::Handle::enter::{{closure}}::h5f23b09497c9134e
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/handle.rs:36
  56:     0x55f230125368 - tokio::runtime::blocking::pool::Spawner::enter::{{closure}}::hdd1db453d0baf707
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/blocking/pool.rs:191
  57:     0x55f230123e55 - std::thread::local::LocalKey<T>::try_with::h3e31b3c882885628
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:262
  58:     0x55f2301238df - std::thread::local::LocalKey<T>::with::h8a8224feb9fcc530
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:239
  59:     0x55f230125258 - tokio::runtime::blocking::pool::Spawner::enter::h24074cc6d3e7c8cf
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/blocking/pool.rs:176
  60:     0x55f230124ce6 - tokio::runtime::handle::Handle::enter::he48e996c2da06878
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/handle.rs:33
  61:     0x55f230124670 - tokio::runtime::Runtime::block_on::h8c07b969cd9d3eb8
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/runtime/mod.rs:406
  62:     0x55f2301224ef - tokio::task::local::LocalSet::block_on::{{closure}}::h17515287e6d327ac
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:310
  63:     0x55f23012262d - tokio::task::local::Scheduler::with::{{closure}}::h7e46c50e9cae45da
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:400
  64:     0x55f2301242b6 - std::thread::local::LocalKey<T>::try_with::ha8bf9ea226acc6d1
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:262
  65:     0x55f2301237bf - std::thread::local::LocalKey<T>::with::h4d4aa64bec1be049
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/thread/local.rs:239
  66:     0x55f230122546 - tokio::task::local::Scheduler::with::h5e93f5606393e9b6
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:396
  67:     0x55f2301223e6 - tokio::task::local::LocalSet::block_on::h41e9162a8d0199a9
                               at /home/omer/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.2/src/task/local.rs:309
  68:     0x55f230125b0c - echo::main::he553ebae486cefa2
                               at libtiny_client/examples/echo.rs:47
  69:     0x55f23011ea50 - std::rt::lang_start::{{closure}}::he00a445ded6267d8
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/rt.rs:61
  70:     0x55f2302c7993 - std::rt::lang_start_internal::{{closure}}::h16dc1ac2088d9f7a
                               at src/libstd/rt.rs:48
  71:     0x55f2302c7993 - std::panicking::try::do_call::h0ce6ab68fad638ec
                               at src/libstd/panicking.rs:287
  72:     0x55f2302cb2ba - __rust_maybe_catch_panic
                               at src/libpanic_unwind/lib.rs:81
  73:     0x55f2302c850d - std::panicking::try::hc9afc7e8c88da3b3
                               at src/libstd/panicking.rs:265
  74:     0x55f2302c850d - std::panic::catch_unwind::hda5772ede2be7694
                               at src/libstd/panic.rs:395
  75:     0x55f2302c850d - std::rt::lang_start_internal::h5c5e596798427697
                               at src/libstd/rt.rs:47
  76:     0x55f23011ea29 - std::rt::lang_start::h45d58bfc206a4c45
                               at /rustc/412f43ac5b4ae8c3599e71c6972112e9be4758fa/src/libstd/rt.rs:61
  77:     0x55f230125d9a - main
  78:     0x7f45bd497b97 - __libc_start_main
  79:     0x55f23011e8fa - _start
  80:                0x0 - <unknown>

Is this a tokio bug?

@osa1 osa1 mentioned this issue Dec 5, 2019
@osa1
Copy link
Owner Author

osa1 commented Dec 5, 2019

In the PR I use tokio-0.2.2 in all crates, but the error above persists.

@FreeFull
Copy link

FreeFull commented Dec 5, 2019

I don't get the error if I replace the line

let mut runtime = tokio::runtime::Builder::new().build().unwrap();

with

let mut runtime = tokio::runtime::Builder::new().enable_time().enable_io().build().unwrap();

or

let mut runtime = tokio::runtime::Runtime::new().unwrap();

in echo.rs. It seems like the timer and io stuff isn't enabled by default with the Builder, but is actually required for tiny to work. Seems best to just create the Runtime directly with Runtime::new() anyway.

@osa1
Copy link
Owner Author

osa1 commented Dec 6, 2019

That's it, thanks @FreeFull ! I wasn't even aware that I can enable/disable features when initializing the runtime..

osa1 added a commit that referenced this issue Dec 6, 2019
osa1 added a commit that referenced this issue Dec 6, 2019
osa1 added a commit that referenced this issue Dec 7, 2019
@osa1
Copy link
Owner Author

osa1 commented Dec 26, 2019

Currently waiting for tokio-rs/tokio#1971 to be merged.

osa1 added a commit that referenced this issue Dec 29, 2019
@osa1
Copy link
Owner Author

osa1 commented Jan 2, 2020

Thinking about this more, if we want libtiny_client to work with different executor then perhaps we should implement graceful shutdown in libtiny_client instead of relying on executor support. More specifically for the GUI I want to be able to run libtiny_client using GTK/Glib's executor, and as far as I can see GTK's MainContext doesn't have a method for this.

osa1 added a commit that referenced this issue Jan 2, 2020
osa1 added a commit that referenced this issue Jan 4, 2020
osa1 added a commit that referenced this issue Jan 8, 2020
@osa1 osa1 closed this as completed in #161 Jan 8, 2020
osa1 added a commit that referenced this issue Jan 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants