Skip to content

Commit

Permalink
Small fixups from launch PR (ros2#77)
Browse files Browse the repository at this point in the history
* fix doc typo

* Check handlers being set

* Remove exception note

* Label linters

* alpha
  • Loading branch information
wjwwood committed Jun 15, 2018
1 parent 86da112 commit dd0ec9d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
12 changes: 9 additions & 3 deletions launch/launch/utilities/signal_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def on_sigint(handler):
It is called automatically by the constructor of `launch.LaunchService`.
"""
global __custom_sigint_handler
if handler is not None and not callable(handler):
raise ValueError('handler must be callable or None')
__custom_sigint_handler = handler


Expand All @@ -58,6 +60,8 @@ def on_sigquit(handler):
It is called automatically by the constructor of `launch.LaunchService`.
"""
global __custom_sigquit_handler
if handler is not None and not callable(handler):
raise ValueError('handler must be callable or None')
__custom_sigquit_handler = handler


Expand All @@ -71,6 +75,8 @@ def on_sigterm(handler):
It is called automatically by the constructor of `launch.LaunchService`.
"""
global __custom_sigterm_handler
if handler is not None and not callable(handler):
raise ValueError('handler must be callable or None')
__custom_sigterm_handler = handler


Expand All @@ -95,8 +101,8 @@ def install_signal_handlers():
If you register signal handlers before calling this function, then your
signal handler will automatically be called by the signal handlers in this
thread.
One exception is that if your handler raises KeyboardInterrupt and a custom
handler for SIGINT has been set with on_sigint, then that exception will be
If your handler for SIGINT raises KeyboardInterrupt, and a custom handler
for SIGINT has been set with on_sigint, then that exception will be
suppressed.
"""
global __signal_handlers_installed_lock, __signal_handlers_installed
Expand Down Expand Up @@ -146,5 +152,5 @@ def __on_sigterm(signum, frame):
signal.signal(signal.SIGQUIT, __on_sigquit)
except ValueError:
_logger.error("failed to set signal handlers in 'launch.utilities.signal_management.py'")
_logger.error('this module must be imported in the main thread')
_logger.error('this function must be called in the main thread')
raise
3 changes: 3 additions & 0 deletions launch/test/test_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# limitations under the License.

from ament_copyright.main import main
import pytest


@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
1 change: 1 addition & 0 deletions launch_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<test_depend>ament_copyright</test_depend>
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
Expand Down
3 changes: 3 additions & 0 deletions launch_ros/test/test_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# limitations under the License.

from ament_copyright.main import main
import pytest


@pytest.mark.copyright
@pytest.mark.linter
def test_copyright():
rc = main(argv=['.', 'test'])
assert rc == 0, 'Found errors'
3 changes: 3 additions & 0 deletions launch_ros/test/test_flake8.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# limitations under the License.

from ament_flake8.main import main
import pytest


@pytest.mark.flake8
@pytest.mark.linter
def test_flake8():
rc = main(argv=[])
assert rc == 0, 'Found errors'
3 changes: 3 additions & 0 deletions launch_ros/test/test_pep257.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
# limitations under the License.

from ament_pep257.main import main
import pytest


@pytest.mark.linter
@pytest.mark.pep257
def test_pep257():
rc = main(argv=[])
assert rc == 0, 'Found code style errors / warnings'

0 comments on commit dd0ec9d

Please sign in to comment.