Skip to content

Commit

Permalink
Socket changes for WASM.
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioz committed Oct 20, 2022
1 parent fc64504 commit ac64657
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 '''
Expand Down Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit ac64657

Please sign in to comment.