From c14b298cb91ceb12ecb0aeac5a8264b6f0f3f7d6 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 19 Mar 2021 15:55:42 +0200 Subject: [PATCH] Fixed an issue with silent hanging when a custom debug server is not found // Resolve #3756 --- HISTORY.rst | 1 + platformio/commands/debug.py | 14 ++++++++------ platformio/debug/process/server.py | 7 +++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 59edd6de..141fba3e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -16,6 +16,7 @@ PlatformIO Core 5 - Boosted `PlatformIO Debugging `__ performance thanks to migrating the codebase to the pure Python 3 Asynchronous I/O stack - Support debugging on Windows using Windows CMD/CLI (`pio debug `__) (`issue #3793 `_) - Configure a custom pattern to determine when debugging server is started with a new `debug_server_ready_pattern `__ option + - Fixed an issue with silent hanging when a custom debug server is not found (`issue #3756 `_) 5.1.1 (2021-03-17) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/commands/debug.py b/platformio/commands/debug.py index c2df11ee..3f468de9 100644 --- a/platformio/commands/debug.py +++ b/platformio/commands/debug.py @@ -155,11 +155,13 @@ def cli(ctx, project_dir, project_conf, environment, verbose, interface, __unpro asyncio.set_event_loop(loop) client = GDBClientProcess(project_dir, debug_config) coro = client.run(__unprocessed) - loop.run_until_complete(coro) - del client - if IS_WINDOWS: - # an issue with asyncio executor and STIDIN, it cannot be closed gracefully - proc.force_exit() - loop.close() + try: + loop.run_until_complete(coro) + if IS_WINDOWS: + # an issue with asyncio executor and STIDIN, it cannot be closed gracefully + proc.force_exit() + finally: + del client + loop.close() return True diff --git a/platformio/debug/process/server.py b/platformio/debug/process/server.py index d1fe5e7d..1fb08f4d 100644 --- a/platformio/debug/process/server.py +++ b/platformio/debug/process/server.py @@ -51,10 +51,9 @@ class DebugServerProcess(DebugBaseProcess): server_executable = where_is_program(server_executable) if not os.path.isfile(server_executable): raise DebugInvalidOptionsError( - "\nCould not launch Debug Server '%s'. Please check that it " - "is installed and is included in a system PATH\n\n" - "See documentation:\n" - "https://docs.platformio.org/page/plus/debugging.html\n" + "Could not launch Debug Server '%s'. Please check that it " + "is installed and is included in a system PATH\n" + "See https://docs.platformio.org/page/plus/debugging.html" % server_executable )