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

fix: allow for recursive block-on calls #799

Merged
merged 4 commits into from
Jun 4, 2020

Conversation

dignifiedquire
Copy link
Member

Depends on smol-rs/smol#147

Fixes #798,#795,#760

@rakshith-ravi
Copy link

Awesome! Now that smol-rs/smol#147 is merged, can we update this and merge this as well?

@dignifiedquire
Copy link
Member Author

Awesome! Now that stjepang/smol#147 is merged, can we update this and merge this as well?

still need to wait for a new release

@dignifiedquire
Copy link
Member Author

CI seems to be failing independently, unclear as to why atm

@dignifiedquire dignifiedquire force-pushed the feat/recursive-block-on branch from e57bf2a to 09840dd Compare June 4, 2020 10:26
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Structurally looks good. Some code quality things I'd like to see addressed. But this is incredibly exciting. Thanks for doing this @dignifiedquire!

@dignifiedquire dignifiedquire merged commit e12cf80 into master Jun 4, 2020
@dignifiedquire dignifiedquire deleted the feat/recursive-block-on branch June 4, 2020 11:19
@rakshith-ravi
Copy link

Awesome! Thanks a ton! Can we create a new release with this?

@rakshith-ravi
Copy link

rakshith-ravi commented Jun 4, 2020

@dignifiedquire I tried pointing the async-std in my Cargo.toml to the master branch and am still getting the same error as #798. Any idea what could be causing this?

Edit: Here's the backtrace in case it helps:

thread 'async-std/runtime' panicked at 'cannot run an executor inside another executor', <::std::macros::panic macros>:2:4
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/backtrace-0.3.44/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1063
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1426
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:204
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:224
  10: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:470
  11: std::panicking::begin_panic
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/panicking.rs:397
  12: smol::work_stealing::Worker::enter
             at ./<::std::macros::panic macros>:2
  13: smol::run::run::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:113
  14: smol::run::run
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:115
  15: async_std::task::builder::Builder::blocking::{{closure}}::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/builder.rs:170
  16: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/task_locals_wrapper.rs:60
  17: std::thread::local::LocalKey<T>::try_with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:262
  18: std::thread::local::LocalKey<T>::with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:239
  19: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/task_locals_wrapper.rs:55
  20: async_std::task::builder::Builder::blocking::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/builder.rs:167
  21: std::thread::local::LocalKey<T>::try_with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:262
  22: std::thread::local::LocalKey<T>::with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:239
  23: async_std::task::builder::Builder::blocking
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/builder.rs:160
  24: async_std::task::block_on::block_on
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/block_on.rs:33
  25: guillotine::host::juno_module::register_node
             at src/host/juno_module.rs:132
  26: juno::juno_module_impl::JunoModuleImpl::execute_function_call::{{closure}}
             at /home/rakshith/Projects/juno/juno-rust/src/juno_module_impl.rs:39
  27: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/future.rs:44
  28: std::future::poll_with_tls_context
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/future.rs:102
  29: juno::juno_module_impl::JunoModuleImpl::on_data::{{closure}}
             at /home/rakshith/Projects/juno/juno-rust/src/juno_module_impl.rs:80
  30: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/future.rs:44
  31: std::future::poll_with_tls_context
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/future.rs:102
  32: juno::connection::unix_socket_connection::read_data_from_socket::{{closure}}::{{closure}}
             at /home/rakshith/Projects/juno/juno-rust/src/connection/unix_socket_connection.rs:136
  33: <std::future::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/future.rs:44
  34: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/builder.rs:198
  35: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/task_locals_wrapper.rs:60
  36: std::thread::local::LocalKey<T>::try_with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:262
  37: std::thread::local::LocalKey<T>::with
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libstd/thread/local.rs:239
  38: async_std::task::task_locals_wrapper::TaskLocalsWrapper::set_current
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/task_locals_wrapper.rs:55
  39: <async_std::task::builder::SupportTaskLocals<F> as core::future::future::Future>::poll
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/task/builder.rs:196
  40: async_task::raw::RawTask<F,R,S,T>::run
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/async-task-3.0.0/src/raw.rs:502
  41: async_task::task::Task<T>::run
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/async-task-3.0.0/src/task.rs:265
  42: smol::work_stealing::Worker::execute::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/work_stealing.rs:176
  43: scoped_tls_hkt::ScopedKey<T>::set
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/scoped-tls-hkt-0.1.2/src/lib.rs:488
  44: smol::throttle::setup
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/throttle.rs:31
  45: smol::work_stealing::Worker::execute
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/work_stealing.rs:176
  46: smol::run::run::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:151
  47: core::ops::function::FnOnce::call_once
             at /rustc/8d69840ab92ea7f4d323420088dd8c9775f180cd/src/libcore/ops/function.rs:232
  48: smol::context::enter
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/context.rs:8
  49: smol::run::run::{{closure}}::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:112
  50: scoped_tls_hkt::ScopedKey<T>::set
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/scoped-tls-hkt-0.1.2/src/lib.rs:488
  51: smol::thread_local::ThreadLocalExecutor::enter
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/thread_local.rs:57
  52: smol::run::run::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:112
  53: smol::run::run::{{closure}}::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:113
  54: smol::work_stealing::WORKER::<impl smol::work_stealing::WORKER>::set
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/<::scoped_tls_hkt::scoped_thread_local macros>:40
  55: smol::work_stealing::Worker::enter
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/work_stealing.rs:149
  56: smol::run::run::{{closure}}
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:113
  57: smol::run::run
             at /home/rakshith/.cargo/registry/src/suiyiyu.us.kg-1ecc6299db9ec823/smol-0.1.11/src/run.rs:115
  58: async_std::rt::RUNTIME::{{closure}}::{{closure}}
             at /home/rakshith/.cargo/git/checkouts/async-std-2413e748fca81ce4/e12cf80/src/rt/mod.rs:30

@dignifiedquire
Copy link
Member Author

dignifiedquire commented Jun 4, 2020 via email

@rakshith-ravi
Copy link

I modified my Cargo.toml to this:

async-std = { git = "https://github.com/async-rs/async-std", branch = "master", features = ["attributes"] }

Smol seems to be updated to 0.1.11, according to the Cargo.lock file. Any help on how to debug this would be appreciated. I'd be happy to test this out before we release the update

@dignifiedquire
Copy link
Member Author

@rakshith-ravi I think I have an idea what the issue is, could you test out this branch: https://github.com/async-rs/async-std/tree/fix/recursive-block-2

@rakshith-ravi
Copy link

Hey @dignifiedquire. Sorry I've been MIA, got busy in a lot of work. That branch shows me a 404. Is there any other way for me to test it?

@rakshith-ravi
Copy link

Okay, just noticed that it got merged into master. And yes, @dignifiedquire I tested it with the current master branch and it seems to work well!

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 this pull request may close these issues.

Bug: task::block_on cannot run on an async context
3 participants