> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# wait_for

> Wait for a specific event on a call.

[relayevent]: /docs/server-sdks/reference/python/relay/events

Wait for a specific event type on this call, optionally filtered by a predicate
function. This is a one-shot listener -- it resolves on the first matching event
and then removes itself.

## **Parameters**

**`event_type`** `str` — required

The event type string to wait for.

---

**`predicate`** `Callable[[RelayEvent], bool] | None` — default: None

Optional filter function. If provided, the wait only resolves when the
predicate returns `True` for a received event.

---

**`timeout`** `float | None` — default: None

Maximum seconds to wait. Raises `asyncio.TimeoutError` if exceeded. `None`
waits indefinitely.

---

## **Returns**

[`RelayEvent`][relayevent] -- The first event matching the type and optional predicate.

## **Example**

```python {15}
from signalwire.relay import RelayClient

client = RelayClient(
    project="your-project-id",
    token="your-api-token",
    contexts=["default"],
)

@client.on_call
async def handle_call(call):
    await call.answer()

    # Wait for a specific play event
    action = await call.play([{"type": "tts", "params": {"text": "Hello!"}}])
    event = await call.wait_for(
        "calling.call.play",
        predicate=lambda e: e.params.get("state") == "finished",
        timeout=30,
    )
    print(f"Play finished: {event.params}")

client.run()
```