Do not swallow errors from ExecuteProcess
I maintainer di solito rispondono entro 1 giorno
@hidmic ci sta già lavorando.
Dal 3/2/2022.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Bug report
Required Info:
- Operating System:
- Ubuntu 20.04
- Installation type:
- binaries
- Version or commit hash:
- 0.17.0
- DDS implementation:
- N/A
- Client library (if applicable):
- N/A
Steps to reproduce issue
repro.py
from launch import LaunchDescription, LaunchService
from launch.actions import ExecuteProcess
def test_fakecommand():
def check_ok_process(event, context):
assert 0 == event.returncode
ls = LaunchService()
ls.include_launch_description(
LaunchDescription(
[
ExecuteProcess(
cmd=["fakecommand"],
on_exit=check_ok_process
)
]
)
)
assert 0 == ls.run()
then run
python3 -m pytest -rP repro.py
Expected behavior
Either expect LaunchService::run() to return a nonzero exit code, or the process to return a nonzero exit code. Either of these cases should cause the test to fail. This sort of test allows me to write automated tests that should validate my launch files.
Actual behavior
The test passes, and the error is swallowed, without an easy way to catch it in the test.
================================= test session starts ==================================
platform linux -- Python 3.8.10, pytest-4.6.9, py-1.8.1, pluggy-0.13.0
rootdir: ...
plugins: ament-lint-0.10.6, ament-mypy-0.10.6, ament-flake8-0.10.6, launch-testing-ros-0.14.2, ament-copyright-0.10.6, ament-pep257-0.10.6, launch-testing-0.17.0, ament-xmllint-0.10.6, colcon-core-0.6.1, cov-2.8.1
collected 1 item
repro.py . [100%]
======================================== PASSES ========================================
________________________________ test_fakecommand ________________________________
--------------------------------- Captured stdout call ---------------------------------
[INFO] [launch]: All log files can be found below ...
[INFO] [launch]: Default logging verbosity is set to INFO
[ERROR] [fakecommand-1]: exception occurred while executing process:
Traceback (most recent call last):
File "/opt/ros/galactic/lib/python3.8/site-packages/launch/actions/execute_process.py", line 737, in __execute_process
transport, self._subprocess_protocol = await async_execute_process(
File "/opt/ros/galactic/lib/python3.8/site-packages/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py", line 139, in async_execute_process
transport, protocol = await _async_execute_process_nopty(
File "/opt/ros/galactic/lib/python3.8/site-packages/osrf_pycommon/process_utils/async_execute_process_asyncio/impl.py", line 45, in _async_execute_process_nopty
transport, protocol = await loop.subprocess_exec(
File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
transport = await self._make_subprocess_transport(
File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
transp = _UnixSubprocessTransport(self, protocol, args, shell,
File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in __init__
self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
self._proc = subprocess.Popen(
File "/usr/lib/python3.8/subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.8/subprocess.py", line 1704, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'fakecommand'
=============================== 1 passed in 0.02 seconds ===============================
Additional information
This behavior is aligns with the exception being swallowed here: https://github.com/ros2/launch/blob/32dbb67a5b74e67c62483c213d3346906d64669e/launch/launch/actions/execute_local.py#L551-L556
I understand that not every error in a process should mean that the entire launch service should return an error. But anything that is a process-level error should result in a ProcessExited event or something to handle it with. This sort of error lives in-between, with nothing good to catch it with.
- Lingua principale
- Python
- Stelle
- 156
- Fork
- 200
- Merge medio
- 2g 11h
- PR unite (30g)
- 11
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ros2/launch
-
Use a relative target for the `latest` log symlink so it survives different absolute mount paths (host/Docker)Forse già presa @Old-Ding l’ha presa 139 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
ros2/launch#978 · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Add OpaqueFunction to list at docs.ros.orgForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ros2/launch#826 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 30/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
[launch_testing] pytest>8.1 dropped the legacy "path" argument from its internal hooks on humbleForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
ros2/launch#979 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
I maintainer di solito rispondono entro 1 giorno
-
hive size:simple
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
backend enhancement priority:P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
geolens-io/geolens#4161 ·
I maintainer di solito rispondono entro 1 giorno