> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# wait

> Wait for waitables to complete, return (done, pending).

소스: [src/cwsandbox/**init**.py:176](https://github.com/coreweave/cwsandbox-client/blob/v1.14.2/src/cwsandbox/__init__.py#L176)

```python theme={"system"}
wait(waitables: Sequence[Waitable], num_returns: int | None = None, timeout: float | None = None) -> tuple[list[Waitable], list[Waitable]]
```

waitable이 완료될 때까지 대기하고 (done, pending)을 반환합니다.

각 waitable 유형에는 고유한 "대기" 동작이 있습니다.

* Sandbox: RUNNING 상태가 될 때까지 대기합니다

* OperationRef: 오퍼레이션이 완료될 때까지 대기합니다

* Process: 프로세스가 완료될 때까지 대기합니다
  **매개변수**

* `waitables` (`Sequence[Waitable]`): Sandbox, OperationRef 또는 Process 객체의 시퀀스입니다.

* `num_returns` (`int | None`): 지정하면 이 개수만큼 완료된 후 반환합니다. None이면 모두 완료될 때까지 대기합니다.

* `timeout` (`float | None`): 최대 대기 시간(초)입니다. None이면 무기한 대기합니다.

**반환값**

* `tuple[list[Waitable], list[Waitable]]`: 원래 waitable 객체가 담긴 (done, pending) 목록의 튜플입니다.

**예외**

* `ValueError`: num\_returns가 1보다 작으면 발생합니다.

**예시**

모든 샌드박스가 실행 중 상태가 될 때까지 대기합니다.

```python theme={"system"}
sandboxes = [Sandbox.run(...) for _ in range(5)]
done, pending = cwsandbox.wait(sandboxes)
```

처음 2개의 오퍼레이션이 완료될 때까지 기다리세요:

```python theme={"system"}
refs = [sb.read_file(f) for f in files]
done, pending = cwsandbox.wait(refs, num_returns=2)
```

timeout을 지정하여 대기:

```python theme={"system"}
done, pending = cwsandbox.wait(procs, timeout=30.0)
```
