diff --git a/contrib/.vscode/launch.json b/contrib/.vscode/launch.json index a10227e4aa..6d04a9973f 100644 --- a/contrib/.vscode/launch.json +++ b/contrib/.vscode/launch.json @@ -66,7 +66,7 @@ "redirectOutput": true, "connect": { "host": "localhost", - "port": 5678 + "port": 5679 }, "pathMappings": [ { diff --git a/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro b/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro index 8901de6b62..7765f9682b 100644 --- a/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro +++ b/contrib/.vscode/scripts/VSCodeAutostartDebug.FCMacro @@ -7,7 +7,11 @@ from freecad.utils import get_python_exe # By default it attempts to use Freecad's PID mistaking it for python. # https://github.com/microsoft/debugpy/issues/262 debugpy.configure(python=get_python_exe()) -debugpy.listen(('localhost', 5678)) +# As of Python 3.12, debugpy runs a forwarding process that listens both on the port specified here for the debugger +# to connect to, but also on an internal port for the underlying pydevd within the python process to connect to. The +# default for that internal port is 5678, so we need to not duplicate it for the external port. Also, on Linux the +# attempt to spawn the forwarding process separately fails, so we force it to be internal to our main process. +debugpy.listen(('localhost', 5679),in_process_debug_adapter=True) # Turns out you cannot probe debugpy to see if it is up: # https://github.com/microsoft/debugpy/issues/974 diff --git a/contrib/.vscode/scripts/WaitForDebugpy.py b/contrib/.vscode/scripts/WaitForDebugpy.py index 4f8f70c899..592389259b 100644 --- a/contrib/.vscode/scripts/WaitForDebugpy.py +++ b/contrib/.vscode/scripts/WaitForDebugpy.py @@ -13,8 +13,8 @@ def check_socket(host, port): return sock.connect_ex((host, port)) == 0 def main(): - # DO NOT CHECK 5678 or debugpy will break - # Check other port manually opened instead + # DO NOT CHECK the actual port 5678/5879 or debugpy will break + # Check that the other port 39999 used as a flag is manually opened instead attempt_counter = 0 while (not check_socket('localhost', 39999)) and attempt_counter < MAX_ATTEMPTS: time.sleep(RETRY_DELAY_S)