Skip to content

Commit e826582

Browse files
Fix race condition
1 parent 2481d51 commit e826582

File tree

1 file changed

+11
-1
lines changed
  • formant_ros2_adapter/scripts

1 file changed

+11
-1
lines changed

formant_ros2_adapter/scripts/main.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
import rclpy
2+
import time
23

34
from formant.sdk.agent.v1 import Client
45

56
from ros2_adapter import ROS2Adapter
7+
from utils.logger import get_logger
8+
9+
10+
FCLIENT_WAIT = 2
611

712

813
if __name__ == "__main__":
14+
logger = get_logger()
915
rclpy.init()
1016
node = rclpy.create_node(
1117
"formant_ros2_adapter",
1218
allow_undeclared_parameters=True,
1319
automatically_declare_parameters_from_overrides=True,
1420
)
15-
fclient = Client(ignore_throttled=True, ignore_unavailable=True)
21+
logger.info("Creating Formant agent client")
22+
# To do: a cleaner solution would have ignore_unavailable=True and
23+
# something implemented in the client to avoid a race condition
24+
fclient = Client(ignore_throttled=True)
25+
logger.info("Waiting %s seconds for Formant agent client" % FCLIENT_WAIT)
1626
ROS2Adapter(fclient, node)
1727
try:
1828
while rclpy.ok():

0 commit comments

Comments
 (0)