esp-idf/tools
Frantisek Hrbata 0de3c3b572 fix: exit gracefully when process started via asyncio is terminated
Currently when process is started through asyncio Runner and it is termited
e.g. with SIGINT(ctrl+c) a traceback is printed instead of gracefully
exit.

Exception ignored in: <function BaseSubprocessTransport.__del__ at 0x7fe980970900>
Traceback (most recent call last):
  File "/usr/lib64/python3.12/asyncio/base_subprocess.py", line 129, in __del__
    self.close()
  File "/usr/lib64/python3.12/asyncio/base_subprocess.py", line 107, in close
    proto.pipe.close()
  File "/usr/lib64/python3.12/asyncio/unix_events.py", line 568, in close
    self._close(None)
  File "/usr/lib64/python3.12/asyncio/unix_events.py", line 592, in _close
    self._loop.call_soon(self._call_connection_lost, exc)
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 793, in call_soon
    self._check_closed()
  File "/usr/lib64/python3.12/asyncio/base_events.py", line 540, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed

This is caused because asyncio Runner context in asyncio.run is closing the event
loop and if exception is unhandled in coroutine(run_command) the transport is not
closed before the even loop is closed and we get RuntimeError: Event loop is closed
in the transport __del__ function because it's trying to use the closed
even loop.

Let's catch asyncio.CancelledError in case the process we are trying to
read from is terminated, print message, let the asyncio finish and exit
gracefully.

Closes https://github.com/espressif/esp-idf/issues/13418

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-04-22 11:51:32 +02:00
..
ble feat: add requirements.ttfw.txt 2022-08-01 15:52:21 +08:00
catch Whitespace: Automated whitespace fixes (large commit) 2020-11-11 07:36:35 +00:00
ci Merge branch 'bugfix/flash_mxic_chip_v5.1' into 'release/v5.1' 2024-03-14 10:46:13 +08:00
cmake fix(menuconfig): Prevent Access violation on Windows with Python 3.12 2024-03-08 14:25:35 +01:00
docker Merge branch 'contrib/github_pr_12637_v5.1' into 'release/v5.1' 2023-12-11 23:09:50 +08:00
esp_app_trace fix(app_trace): Fix SystemView build 2023-12-28 12:08:57 +04:00
esp_prov fix(esp_prov): update devices tuple usage due to API deprecations 2023-08-24 14:48:25 +05:30
gen_soc_caps_kconfig build-system: include soc_caps defines into kconfig 2021-12-06 12:37:07 +08:00
idf_py_actions fix: exit gracefully when process started via asyncio is terminated 2024-04-22 11:51:32 +02:00
kconfig_new fix(menuconfig): Prevent Access violation on Windows with Python 3.12 2024-03-08 14:25:35 +01:00
ldgen change(esp_hw_support/sleep): rename ESP_SLEEP_DEEP_SLEEP_WAKEUP_DELAY 2023-12-27 15:36:20 +08:00
mass_mfg tools: remove the dependency on the future package 2022-08-09 16:46:58 +02:00
mocks [tcp_transport] - Adds Socks4 proxy transport 2023-03-27 14:46:40 +02:00
requirements Revert "Merge branch 'update/littlefs_demo_example_v5.1' into 'release/v5.1'" 2024-03-06 18:34:14 +01:00
templates/sample_component add new command to idf 2020-09-21 23:38:52 +02:00
test_apps fix(esp_hw_support): Fix the flash I/DROM region PMP protection 2024-04-03 15:51:39 +05:30
test_build_system feat(ci): add test for custom cmake CMAKE_EXECUTABLE_SUFFIX 2023-11-20 11:03:28 +01:00
test_idf_py fix: harden input parsing in component_requirements hint module 2024-01-25 14:20:22 +01:00
test_idf_tools fix(tools): catch more general errors in python dependency checker 2024-02-22 15:51:47 +01:00
test_mkdfu mkdfu.py: Support setting flash parameters 2022-05-27 15:44:56 +02:00
test_mkuf2 idf.py: Change copyright in tools dir 2022-05-24 14:01:50 +02:00
unit-test-app Merge branch 'refactor/driver_ut_to_test_app_v5.1' into 'release/v5.1' 2023-05-18 16:18:26 +08:00
check_python_dependencies.py fix(tools): catch more general errors in python dependency checker 2024-02-22 15:51:47 +01:00
check_term.py check_term: allow alacritty term 2022-05-19 11:10:59 +08:00
detect_python.fish Tools: Use default value in the Python detections scripts 2022-03-11 11:00:31 +01:00
detect_python.sh Tools: Use default value in the Python detections scripts 2022-03-11 11:00:31 +01:00
eclipse-code-style.xml tools: add code formatter rules for Eclipse 2016-11-03 18:41:00 +08:00
format-minimal.sh global: use '/usr/bin/env bash' instead of '/usr/bin/bash' in shebangs 2020-04-03 01:10:02 +02:00
format.sh global: use '/usr/bin/env bash' instead of '/usr/bin/bash' in shebangs 2020-04-03 01:10:02 +02:00
gdb_panic_server.py feat(tools): remove gdb_panic_server and use just a wrapper for script 2023-09-08 09:34:12 +02:00
gen_esp_err_to_name.py tool: skip test folder when generating esp_err_t table 2022-11-10 10:37:59 +08:00
generate_debug_prefix_map.py build: create BUILD_DIR/prefix_map_gdbinit when enable reproducible build 2021-10-26 10:55:00 +08:00
idf_monitor.py feat(idf_monitor): move idf_monitor to separate repo 2023-02-03 11:20:15 +01:00
idf_size.py tools: Move out idf_size.py in favour of using the esp-idf-size package 2023-03-27 19:40:33 +02:00
idf_tools.py fix(tools): Add additional Python installation checks 2024-03-01 16:01:03 +01:00
idf.py fix(tools): extend error message for failed python module import 2023-09-08 07:29:43 +02:00
install_util.py Tools: --disable-* argument for removing features 2022-06-30 12:31:59 +02:00
mkdfu.py tools: remove the dependency on the future package 2022-08-09 16:46:58 +02:00
mkuf2.py Merge branch 'fix/flake8_v5_warnings' into 'master' 2022-08-12 23:27:14 +08:00
python_version_checker.py Tools: Fix silent failure about the incompatible Python 2022-02-16 18:44:13 +01:00
requirements_schema.json Tools: Make easier the detection of the list of Python features 2022-02-03 19:02:14 +01:00
requirements.json feat: add requirements.ttfw.txt 2022-08-01 15:52:21 +08:00
set-submodules-to-github.sh global: use '/usr/bin/env bash' instead of '/usr/bin/bash' in shebangs 2020-04-03 01:10:02 +02:00
split_paths_by_spaces.py tools: fixup version references related to paths with spaces 2022-05-02 19:05:47 +02:00
tools_schema.json tools: add esp-rom-elfs version '20220823' 2022-09-21 22:39:03 +04:00
tools.json feat(tools): update gdb version to 12.1_20231023 2023-12-18 17:44:22 +08:00