RELAYMessage

wait

View as MarkdownOpen in Claude

Block until the message reaches a terminal state (delivered, undelivered, or failed). Returns the terminal RelayEvent.

Raises asyncio.TimeoutError if timeout is specified and the message does not reach a terminal state within the given duration.

Parameters

timeout
Optional[float]

Maximum number of seconds to wait. None waits indefinitely.

Returns

RelayEvent — The event that caused the message to reach its terminal state. Inspect message.state for the final state value.

Example

1import asyncio
2from signalwire.relay import RelayClient
3
4client = RelayClient(
5 project="your-project-id",
6 token="your-api-token",
7 host="your-space.signalwire.com",
8 contexts=["default"],
9)
10
11async def send_with_timeout():
12 async with client:
13 message = await client.send_message(
14 to_number="+15551234567",
15 from_number="+15559876543",
16 body="Your verification code is 123456",
17 )
18
19 try:
20 event = await message.wait(timeout=30)
21 if message.state == "delivered":
22 print("Message delivered successfully")
23 else:
24 print(f"Message failed: {message.reason}")
25 except asyncio.TimeoutError:
26 print("Timed out waiting for delivery confirmation")
27
28asyncio.run(send_with_timeout())