Skip to content

Commit

Permalink
fix: add retry for init LTTng (#200)
Browse files Browse the repository at this point in the history
* fix: add retry for init LTTng

Signed-off-by: takeshi.iwanari <[email protected]>

* Update ros2caret/verb/record.py

Co-authored-by: ymski <[email protected]>

* Update ros2caret/verb/record.py

Co-authored-by: ymski <[email protected]>

---------

Signed-off-by: takeshi.iwanari <[email protected]>
Co-authored-by: ymski <[email protected]>
  • Loading branch information
iwatake2222 and ymski authored Nov 19, 2024
1 parent 731ba14 commit 855df15
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ros2caret/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ def add_arguments(self, parser, cli_name):
parser.add_argument(
'-c', '--record-clock', dest='record_clock', action='store_true',
help='launch the node where the /clock topic is stored to use ROS time. ')
parser.add_argument(
'--init-retry-num', dest='init_retry_num', type=int,
default=10,
help='retry num to initialize LTTng')

def main(self, *, args):
if args.light_mode:
Expand Down Expand Up @@ -221,7 +225,16 @@ def main(self, *, args):
raise ValueError('--subbuffer-size-kernel value must be power of two.')
init_args['subbuffer_size_kernel'] = args.subbuffer_size_kernel
init_args['immediate'] = args.immediate
init(**init_args)

for i in range(args.init_retry_num):
init_result = init(**init_args)
if init_result:
break
print(f'Failed to init LTTng. retry {i} / {args.init_retry_num}')
time.sleep(1)
else:
print('Failed to init LTTng.')
exit(0)

def _run():
recordable_node_num = node.start(args.verbose, args.recording_frequency)
Expand All @@ -230,7 +243,7 @@ def _run():
try:
input('press enter to stop...')
except EOFError:
print('\nstd::input is not supported in this system. press ctrl-c to stop...')
print('\nstd::input is not supported in this system.\npress ctrl-c to stop...')
while True:
time.sleep(10)

Expand Down

0 comments on commit 855df15

Please sign in to comment.