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

debian-packaging: how to use the crate in multi_threaded tokio runtime? #25

Open
sify21 opened this issue Dec 7, 2024 · 2 comments · May be fixed by #26
Open

debian-packaging: how to use the crate in multi_threaded tokio runtime? #25

sify21 opened this issue Dec 7, 2024 · 2 comments · May be fixed by #26

Comments

@sify21
Copy link

sify21 commented Dec 7, 2024

Qutting https://stackoverflow.com/questions/75079221/future-created-by-async-block-is-not-send

The tokio Runtime is usually multi-threaded, meaning that at any .await point your task could get moved from one thread to another. That's why everything that is held across an .await point must be Send.

I also intend to use in async_trait methods, which by default require Send.

However, many structs in debian-packaging are not Send. For example, I want to unpack data_tar_reader inside BinaryPackageEntry, which causes errors like this:

error: future cannot be sent between threads safely
..... some code here
    | |_____^ future created by async block is not `Send`
    |
    = help: the trait `std::marker::Send` is not implemented for `(dyn futures::AsyncRead + Unpin + 'static)`
note: future is not `Send` as this value is used across an await
241 |     while let Some(Ok(e)) = a.next_entry() {
    |                       - has type `BinaryPackageEntry` which is not `Send`
...
282 |                 data_tar_reader.into_inner().unpack(&dst).await?;
    |                                                           ^^^^^ await occurs here, with `e` maybe used later
@sify21
Copy link
Author

sify21 commented Dec 7, 2024

Maybe this is related
dignifiedquire/async-tar#3

@indygreg
Copy link
Owner

indygreg commented Dec 7, 2024

This is an oversight on my part. PRs to add Send where appropriate will be accepted.

sify21 added a commit to sify21/linux-packaging-rs that referenced this issue Dec 8, 2024
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