Skip to content

Commit

Permalink
REQREPLY-221: Apply PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
albertorobles2000 committed Nov 5, 2024
1 parent 88f3f38 commit cd27094
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ inline ApplicationArguments parse_arguments(int argc, char *argv[], bool client)
unsigned int domain_id = 0;
unsigned int quantity = 1;
unsigned int delay = 0;
unsigned int service_timeout = 60;
unsigned int service_timeout = INT32_MAX;
std::string item_name = "";
bool add = true;
rti::config::Verbosity verbosity(rti::config::Verbosity::EXCEPTION);
Expand Down Expand Up @@ -165,7 +165,7 @@ inline ApplicationArguments parse_arguments(int argc, char *argv[], bool client)
" -q, --quantity <int> Number of items to add or remove\n"\
" Default: 1\n"
" -s, --service-timeout <int> Numbers of senconds the service will run\n"\
" Default: 60\n"
" Default: infinite\n"
" -v, --verbosity <int> How much debugging output to show.\n"\
" Range: 0-3 \n"
" Default: 1"
Expand Down
2 changes: 1 addition & 1 deletion examples/connext_dds/remote_procedure_call/py/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ If you want to modify the DDS Service in the idl you will have to re-generate
the service code using **rtiddsgen**

```sh
<install dir>/bin/rtiddsgen -language Python -replace Inventory.idl
<install dir>/bin/rtiddsgen -language Python -update typefiles Inventory.idl
```

Where `<install dir>` refers to your RTI Connext installation.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@ class InventoryClient(InventoryService, rpc.ClientBase):
...


async def wait_for_service(client: InventoryClient):
while client.matched_service_count == 0:
await sleep(0.1)


async def run_client(args):
participant = dds.DomainParticipant(args.domain)
client = InventoryClient(
participant, "Inventory", max_wait_per_call=dds.Duration(20)
)

# Wait until the service is started
await client.wait_for_service_async(dds.Duration(20))
# For versions 7.4.0 and below:
await wait_for_service(client)
# For newer versions you can use the following:
#await client.wait_for_service_async(dds.Duration(20))

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

import argparse
import asyncio
import sys
import rti.connextdds as dds
import rti.rpc as rpc
import rti.asyncio
Expand Down Expand Up @@ -88,10 +89,10 @@ async def main():

parser.add_argument(
"-s",
"--server-timeout",
"--service-timeout",
type=int,
default=60,
help="Numbers of senconds the service will run (default: 60)",
default=sys.maxsize,
help="Numbers of senconds the service will run (default: infinite)",
)

args = parser.parse_args()
Expand All @@ -102,7 +103,7 @@ async def main():
print("InventoryService running...")
service_task = asyncio.create_task(run_service(service))

await asyncio.sleep(args.server_timeout)
await asyncio.sleep(args.service_timeout)

service_task.cancel()

Expand Down
18 changes: 5 additions & 13 deletions examples/connext_dds/request_reply/cs/PrimesProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,9 @@ public static async Task Main(string[] args)
}

// Set up signal handler to Dispose the DDS entities
var cancellationSource = new CancellationTokenSource();
var timeoutTask = Task.Delay(TimeSpan.FromSeconds(arguments.Timeout), cancellationSource.Token)
.ContinueWith(_ =>
{
if (!cancellationSource.IsCancellationRequested)
{
Console.WriteLine("Shutting down due to timeout...");
cancellationSource.Cancel();
}
}, TaskScheduler.Default);

var cancellationSource = arguments.Timeout > 0
? new CancellationTokenSource(TimeSpan.FromSeconds(arguments.Timeout))
: new CancellationTokenSource();
Console.CancelKeyPress += (_, eventArgs) =>
{
Console.WriteLine("Shutting down...");
Expand Down Expand Up @@ -138,8 +130,8 @@ private static Arguments ParseArguments(string[] args)
getDefaultValue: () => 5),
new System.CommandLine.Option<int>(
new string[] { "--timeout" },
getDefaultValue: () => 120,
description: "Timeout in seconds to wait for the application to finish")
getDefaultValue: () => 0,
description: "Timeout in seconds to wait for the application to finish (default: infinite)"),
};

rootCommand.Description = "Example RTI Connext Requester and Replier";
Expand Down
8 changes: 7 additions & 1 deletion tutorials/rpc/py/robot_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
class RobotControlClient(RobotControl, rpc.ClientBase):
pass

async def wait_for_service(client: RobotControlClient):
while client.matched_service_count == 0:
await sleep(0.1)

async def main():
participant = dds.DomainParticipant(domain_id=0)
client = RobotControlClient(participant, "MyRobotControl")

await client.wait_for_service_async(dds.Duration(20))
# For versions 7.4.0 and below:
await wait_for_service(client)
# For newer versions you can use the following:
# await client.wait_for_service_async(dds.Duration(20))

print("Calling walk_to...")
result = await client.walk_to(
Expand Down

0 comments on commit cd27094

Please sign in to comment.