Skip to content

Commit b032efe

Browse files
authored
wait for the publisher before test command is executed. (#1094)
Signed-off-by: Tomoya Fujita <[email protected]>
1 parent a22b39b commit b032efe

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

ros2topic/test/test_bw_delay_hz.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,15 @@ def publish_message():
145145

146146
publish_timer = self.node.create_timer(0.5, publish_message)
147147

148+
# Wait for the publisher to be discovered
149+
publisher_count = 0
150+
timeout_count = 0
151+
while publisher_count == 0 and timeout_count < 10:
152+
self.executor.spin_once(timeout_sec=0.1)
153+
publisher_count = self.node.count_publishers(topic)
154+
timeout_count += 1
155+
assert publisher_count > 0, 'Publisher was not discovered'
156+
148157
try:
149158
command_action = ExecuteProcess(
150159
cmd=(['ros2', 'topic', verb] +

0 commit comments

Comments
 (0)