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
Currently poll_for_updates is !Send. It would be nice if it could be made Send.
Background
Because poll_for_updates is !Send, it can't be spawned using tokio::spawn or other similar methods and must be on either an actual thread or a local task set. This is not super ergonomic: a common pattern in async applications seems to be spawning persistent tasks like poll_for_updates with tokio::spawn in a 'fire and forget' manner.
Solution suggestions
I haven't looked at the code yet to see if making the function Send is an easy or hard task.
The text was updated successfully, but these errors were encountered:
I am trying to reproduce this issue in the test suite.
spawn(async{ client.poll_for_updates().await;});
The above code fails with this error in the project I'm using:
error: generator cannot be sent between threads safely
--> 87:5
|
87 | tokio::spawn(async {
| ^^^^^^^^^^^^ future created by async block is not `Send`
|
= help: the trait `std::marker::Send` is not implemented for `dyn StdError`
note: required by a bound in `tokio::spawn`
--> /Users/sky/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.18.2/src/task/spawn.rs:127:21
|
127 | T: Future + Send + 'static,
| ^^^^ required by this bound in `tokio::spawn`
I can't reproduce the error with similar code in the test suite, so further investigation is required.
Describe the feature request
Currently
poll_for_updates
is!Send
. It would be nice if it could be madeSend
.Background
Because
poll_for_updates
is!Send
, it can't be spawned usingtokio::spawn
or other similar methods and must be on either an actual thread or a local task set. This is not super ergonomic: a common pattern in async applications seems to be spawning persistent tasks likepoll_for_updates
withtokio::spawn
in a 'fire and forget' manner.Solution suggestions
I haven't looked at the code yet to see if making the function
Send
is an easy or hard task.The text was updated successfully, but these errors were encountered: