Skip to content

Commit eb8092d

Browse files
Update RPC python example and tutorial to use wait_for_service_async (#733)
* Custom transport example: note about doc out of date * Update RPC python example and tutorial to use wait_for_service_async The new API is available since 7.5 and can be now used the latest code examples
1 parent 3d10f72 commit eb8092d

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

examples/connext_dds/remote_procedure_call/py/inventory_client.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,13 @@ class InventoryClient(InventoryService, rpc.ClientBase):
2121
...
2222

2323

24-
async def wait_for_service(client: InventoryClient):
25-
while client.matched_service_count == 0:
26-
await sleep(0.1)
27-
28-
2924
async def run_client(args):
3025
participant = dds.DomainParticipant(args.domain)
3126
client = InventoryClient(
3227
participant, "Inventory", max_wait_per_call=dds.Duration(20)
3328
)
3429

35-
# For versions 7.4.0 and below:
36-
await wait_for_service(client)
37-
# For newer versions you can use the following:
38-
# await client.wait_for_service_async(dds.Duration(20))
30+
await client.wait_for_service_async(dds.Duration(20))
3931

4032
print("Initial inventory: ", await client.get_inventory())
4133

tutorials/rpc/py/robot_client.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,7 @@ async def main():
2424
participant = dds.DomainParticipant(domain_id=0)
2525
client = RobotControlClient(participant, "MyRobotControl")
2626

27-
# For versions 7.4.0 and below:
28-
sleep(2)
29-
# For newer versions you can use the following:
30-
# await client.wait_for_service_async(dds.Duration(20))
27+
await client.wait_for_service_async(dds.Duration(20)) # Available in Connext 7.5.0+
3128

3229
print("Calling walk_to...")
3330
result = await client.walk_to(

0 commit comments

Comments
 (0)