-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Should Client (and its Futures) implement Send? #1082
Comments
The Client in hyper does not implement Send. It currently makes use of some types, like Rc and unsync channel, that prevents it. They could be replaced with Send versions, but it'd be at a performance cost. Is there a reason you're try to send it to another thread? |
I do not send it to another thread. Edit: It is indeed caused by let client = Client::new(&handle);
let future = client.get(url).map_err(|_| ()).and_then(|res| {
res.body().map_err(|_| ()).fold(vec![], |mut acc, chunk| {
acc.extend_from_slice(&chunk);
Ok(acc)
})
})
.map_err(|_| ())
.boxed(); It is normal behaviour? Edit 2: I've fixed my library to use |
It is possible for hyper to change its implementation of |
Personally, I'd rather have the user of |
After having looked into it, it'd be rather difficult to change. Tokio's |
All fine from my POV - as long as you do not make it Send by default :-) |
I'm trying to use hyper with tokio 0.1 now and it's basically impossible despite the shim in the new tokio-core. With this pull request in tokio-core it's now generally possible to The only way to spawn without the |
Yes, the
|
This has been done in master, and will be part of 0.12.0. |
Hello.
I want to rewrite the
http
example of my library to usehyper
since it is now based ontokio
.Here is my attempt at doing so.
It does not compile. I get the following error:
So I wonder if there is a type that is not
Send
inhyper
.Or perhaps it is caused by something else.
Could you please help me to make this example working?
By the way, is there a better way to write the
http_get
function?I would like to keep the error instead of ignoring it.
And I wonder how to avoid using
fold
.Thanks for your help.
The text was updated successfully, but these errors were encountered: