Skip to content

Convert logging mutex functions to pybind11 - #735

Merged
sloretz merged 6 commits into
masterfrom
pybind11_logging_mutex_funcs
Mar 29, 2021
Merged

sloretz merged 6 commits into
masterfrom
pybind11_logging_mutex_funcs

Conversation

@sloretz

@sloretz sloretz commented Mar 24, 2021

Copy link
Copy Markdown
Contributor

Part of #665

Converts these functions to pybind11

  • rclpy_logging_configure
  • rclpy_logging_fini
  • rclpy_create_node

@sloretz sloretz self-assigned this Mar 24, 2021
@sloretz

sloretz commented Mar 24, 2021

Copy link
Copy Markdown
Contributor Author

CI (build: --packages-up-to rclpy test: --packages-select rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz sloretz changed the title Pybind11 logging mutex funcs Convert logging mutex functions to pybind11 Mar 24, 2021
@sloretz sloretz mentioned this pull request Mar 24, 2021
32 of 34 tasks
@sloretz
sloretz force-pushed the pybind11_logging_mutex_funcs branch from 4fa053c to 4a901ce Compare March 24, 2021 21:12

@hidmic hidmic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM !

#include "logging.hpp"

extern "C"
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloretz meta: why the extern "C" block? AFAIK it only affects the function symbol, C and C++ are ABI compatible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On a related note, we should probably ensure symbol locality (i.e. static, anonymous namespace).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I mistakenly thought extern "C" changed the calling convention, but it does not. Removed extern C stuff and made appropriate functions static in 570b63d

Comment thread rclpy/src/rclpy/node.cpp
}

if (RCL_RET_BAD_ALLOC == ret) {
throw std::bad_alloc();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloretz consider doing rcl_reset_error() before throwing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reset the rcl error in 336ca4f

@sloretz

sloretz commented Mar 24, 2021

Copy link
Copy Markdown
Contributor Author

CI with feedback addressed

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz
sloretz force-pushed the pybind11_logging_mutex_funcs branch from 570b63d to fbe3fda Compare March 25, 2021 17:35
@sloretz

sloretz commented Mar 25, 2021

Copy link
Copy Markdown
Contributor Author

Rebased, and running windows CI to hopefully get a line number number for the warning

Windows: Build Status

@sloretz

sloretz commented Mar 25, 2021

Copy link
Copy Markdown
Contributor Author

Windows CI with hopefully a fix for the warning: Build Status

@hidmic hidmic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM !

Comment thread rclpy/src/rclpy/logging.cpp Outdated
try {
rclpy::LoggingGuard scoped_logging_guard;
rcl_logging_multiple_output_handler(location, severity, name, timestamp, format, args);
} catch (std::exception & ex) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloretz nit: could be made const?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made exception catching const in 6dee6f8

@sloretz
sloretz force-pushed the pybind11_logging_mutex_funcs branch from b9d6b31 to 1f2ab6b Compare March 29, 2021 16:29
Signed-off-by: Shane Loretz <[email protected]>
@sloretz

sloretz commented Mar 29, 2021

Copy link
Copy Markdown
Contributor Author

Rebased, CI (build: --packages-above-and-dependencies rclpy test: --packages-above rclpy)

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@sloretz

sloretz commented Mar 29, 2021

Copy link
Copy Markdown
Contributor Author

CMake warning is in cyclondedds, not this PR. Merging 🎉

@sloretz
sloretz merged commit 28bcd82 into master Mar 29, 2021
@delete-merged-branch
delete-merged-branch Bot deleted the pybind11_logging_mutex_funcs branch March 29, 2021 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants