From ac6465760a1041328f875d84adf333fbd44c40c0 Mon Sep 17 00:00:00 2001 From: Fabio Zadrozny Date: Thu, 20 Oct 2022 10:27:45 -0300 Subject: [PATCH] Socket changes for WASM. --- .../_vendored/pydevd/_pydevd_bundle/pydevd_comm.py | 10 +++++----- .../pydevd/_pydevd_bundle/pydevd_constants.py | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py index 8fd522298..a0acbb9ae 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py @@ -70,7 +70,7 @@ from _pydev_bundle._pydev_saved_modules import time from _pydev_bundle._pydev_saved_modules import threading from _pydev_bundle._pydev_saved_modules import socket as socket_module -from _pydevd_bundle.pydevd_constants import (DebugInfoHolder, IS_WINDOWS, IS_JYTHON, +from _pydevd_bundle.pydevd_constants import (DebugInfoHolder, IS_WINDOWS, IS_JYTHON, IS_WASM, IS_PY36_OR_GREATER, STATE_RUN, ASYNC_EVAL_TIMEOUT_SEC, get_global_debugger, GetGlobalDebugger, set_global_debugger, # Keep for backward compatibility @UnusedImport silence_warnings_decorator, filter_all_warnings) @@ -113,19 +113,19 @@ from _pydevd_bundle.pydevd_comm_constants import * # @UnusedWildImport # Socket import aliases: -AF_INET, SOCK_STREAM, SHUT_WR, SOL_SOCKET, SO_REUSEADDR, IPPROTO_TCP, socket = ( +AF_INET, SOCK_STREAM, SHUT_WR, SOL_SOCKET, IPPROTO_TCP, socket = ( socket_module.AF_INET, socket_module.SOCK_STREAM, socket_module.SHUT_WR, socket_module.SOL_SOCKET, - socket_module.SO_REUSEADDR, socket_module.IPPROTO_TCP, socket_module.socket, ) if IS_WINDOWS and not IS_JYTHON: SO_EXCLUSIVEADDRUSE = socket_module.SO_EXCLUSIVEADDRUSE - +if not IS_WASM: + SO_REUSEADDR = socket_module.SO_REUSEADDR class ReaderThread(PyDBDaemonThread): ''' reader thread reads and dispatches commands in an infinite loop ''' @@ -431,7 +431,7 @@ def create_server_socket(host, port): server = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) if IS_WINDOWS and not IS_JYTHON: server.setsockopt(SOL_SOCKET, SO_EXCLUSIVEADDRUSE, 1) - else: + elif not IS_WASM: server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) server.bind((host, port)) diff --git a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py index a9bd9308a..01d1951f5 100644 --- a/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py +++ b/src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_constants.py @@ -94,6 +94,7 @@ def get_frame(): IS_WINDOWS = sys.platform == 'win32' IS_LINUX = sys.platform in ('linux', 'linux2') IS_MAC = sys.platform == 'darwin' +IS_WASM = sys.platform == 'emscripten' or sys.platform == 'wasi' IS_64BIT_PROCESS = sys.maxsize > (2 ** 32)