# tee_peer

> **Function** in `langchain_core`

📖 [View in docs](https://reference.langchain.com/python/langchain-core/utils/iter/tee_peer)

An individual iterator of a `.tee`.

This function is a generator that yields items from the shared iterator `iterator`.
It buffers items until the least advanced iterator has yielded them as well. The
buffer is shared with all other peers.

## Signature

```python
tee_peer(
    iterator: Iterator[T],
    buffer: deque[T],
    peers: list[deque[T]],
    lock: AbstractContextManager[Any],
) -> Generator[T, None, None]
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `iterator` | `Iterator[T]` | Yes | The shared iterator. |
| `buffer` | `deque[T]` | Yes | The buffer for this peer. |
| `peers` | `list[deque[T]]` | Yes | The buffers of all peers. |
| `lock` | `AbstractContextManager[Any]` | Yes | The lock to synchronise access to the shared buffers. |

---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/9f232caa7a8fe1ca042a401942d5d90d54ceb1a6/libs/core/langchain_core/utils/iter.py#L35)