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

Make poll_for_updates Send #34

Closed
skairunner opened this issue May 23, 2022 · 2 comments
Closed

Make poll_for_updates Send #34

skairunner opened this issue May 23, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@skairunner
Copy link

Describe the feature request

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.

@skairunner skairunner added the enhancement New feature or request label May 23, 2022
@skairunner skairunner changed the title poll_for_updates could be Send Make poll_for_updates Send May 23, 2022
@skairunner
Copy link
Author

skairunner commented May 23, 2022

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.

@skairunner
Copy link
Author

It seems that the issue is currently fixed on the master branch, while I'm using 0.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

1 participant