---
title: select_handles
summary: Given a collection of PendingRequestHandles, block until the result of one of the handles is ready.
url: https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/fn.select_handles/
---

**Kind:** Function  
**Module:** [handle](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/)  
**Package:** fastly 0.13.1  
**Source:** https://docs.rs/crate/fastly/0.13.1/source/src/http/request/pending/handle.rs#295

```rust
fn select_handles<I>(pending_reqs: I) -> (Result<(ResponseHandle, BodyHandle), SendErrorCause>, usize, Vec<PendingRequestHandle>)
where
    I: IntoIterator<Item = PendingRequestHandle>,
```

Given a collection of [`PendingRequestHandle`](https://www.fastly.com/documentation/reference/compute/sdks/rust/fastly/handle/struct.PendingRequestHandle/)s, block until the result of one of the handles is
ready.

This function accepts any type which can become an iterator that yields handles; a common choice
is `Vec<PendingRequestHandle>`.

Returns a tuple `(result, index, remaining)`, where:

- `result` is the result of the handle that became ready.

- `index` is the index of the handle in the argument collection (e.g., the index of the handle
in a vector) that became ready.

- `remaining` is a vector containing all of the handles that did not become ready. The order of
the handles in this vector is not guaranteed to match the order of the handles in the argument
collection.

###### Panics

Panics if the argument collection is empty, or contains more than
[`fastly_shared::MAX_PENDING_REQS`](https://docs.rs/fastly_shared/latest/fastly_shared/constant.MAX_PENDING_REQS.html) handles.

**Parameters**

- `pending_reqs`: `I`

**Returns**

`(Result<(crate::handle::ResponseHandle, crate::handle::BodyHandle), crate::http::request::SendErrorCause>, usize, Vec<PendingRequestHandle>)`
