Skip to content

Commit

Permalink
Avoid passing exception KeyboardInterrupt to the upper layer (ros2#788)…
Browse files Browse the repository at this point in the history
… (ros2#942)

* Avoid passing exception KeyboardInterrupt to the upper layer

Signed-off-by: Barry Xu <barry.xu@sony.com>

Signed-off-by: Barry Xu <barry.xu@sony.com>
Co-authored-by: Barry Xu <barry.xu@sony.com>
  • Loading branch information
bin-i and Barry-Xu-2018 authored Sep 29, 2022
1 parent 25a280d commit 67564a4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
48 changes: 25 additions & 23 deletions ros2bag/ros2bag/verb/record.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,31 @@ def main(self, *, args): # noqa: D102
# extension. Therefore, do not import rosbag2_transport at the module
# level but on demand, right before first use.
from rosbag2_transport import rosbag2_transport_py

rosbag2_transport_py.record(
uri=uri,
storage_id=args.storage,
serialization_format=args.serialization_format,
node_prefix=NODE_NAME_PREFIX,
compression_mode=args.compression_mode,
compression_format=args.compression_format,
compression_queue_size=args.compression_queue_size,
compression_threads=args.compression_threads,
all=args.all,
no_discovery=args.no_discovery,
polling_interval=args.polling_interval,
max_bagfile_size=args.max_bag_size,
max_bagfile_duration=args.max_bag_duration,
max_cache_size=args.max_cache_size,
topics=args.topics,
regex=args.regex,
exclude=args.exclude,
include_hidden_topics=args.include_hidden_topics,
qos_profile_overrides=qos_profile_overrides,
storage_preset_profile=args.storage_preset_profile,
storage_config_file=storage_config_file)
try:
rosbag2_transport_py.record(
uri=uri,
storage_id=args.storage,
serialization_format=args.serialization_format,
node_prefix=NODE_NAME_PREFIX,
compression_mode=args.compression_mode,
compression_format=args.compression_format,
compression_queue_size=args.compression_queue_size,
compression_threads=args.compression_threads,
all=args.all,
no_discovery=args.no_discovery,
polling_interval=args.polling_interval,
max_bagfile_size=args.max_bag_size,
max_bagfile_duration=args.max_bag_duration,
max_cache_size=args.max_cache_size,
topics=args.topics,
regex=args.regex,
exclude=args.exclude,
include_hidden_topics=args.include_hidden_topics,
qos_profile_overrides=qos_profile_overrides,
storage_preset_profile=args.storage_preset_profile,
storage_config_file=storage_config_file)
except KeyboardInterrupt:
pass

if os.path.isdir(uri) and not os.listdir(uri):
os.rmdir(uri)
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void stop_execution(const ProcessHandle & handle, int signum = SIGINT)
waitpid(handle, &child_return_code, 0);
// this call will make sure that the process does execute without issues before it is killed by
// the user in the test or, in case it runs until completion, that it has correctly executed.
EXPECT_THAT(WEXITSTATUS(child_return_code), Not(Eq(EXIT_FAILURE)));
EXPECT_THAT(WEXITSTATUS(child_return_code), EXIT_SUCCESS);
}

#endif // ROSBAG2_TEST_COMMON__PROCESS_EXECUTION_HELPERS_UNIX_HPP_

0 comments on commit 67564a4

Please sign in to comment.