RelayCall

wait_for_ending

View as MarkdownOpen in Claude

Wait until the call state reaches ending. Returns immediately if the call is already ending or has moved past it (ended). A typed convenience over wait_for() on the calling.call.state event.

Parameters

timeout
float | NoneDefaults to None

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

Returns

RelayEvent — The state event. When the call was already at or past the target, event.params["call_state"] holds the current state.

Example

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()
await (await call.play_tts("Goodbye.")).wait()
await call.hangup()
await call.wait_for_ending(timeout=10)
client.run()