Skip to content

Commit

Permalink
Fix socket problem when running with Emscripten CPython build (#1077)
Browse files Browse the repository at this point in the history
* SO_REUSEADDR is not supported in EMSCRIPTEN

* Review feedback, make handling SO_REUSEADDR behave like other options

* Remove accidental import

* Fix formatting
  • Loading branch information
rchiodo authored Oct 5, 2022
1 parent 7c8172e commit 646d921
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/debugpy/common/sockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def _new_sock():
if sys.platform == "win32":
sock.setsockopt(socket.SOL_SOCKET, socket.SO_EXCLUSIVEADDRUSE, 1)
else:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
try:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
except (AttributeError, OSError):
pass # Not available everywhere

# Set TCP keepalive on an open socket.
# It activates after 1 second (TCP_KEEPIDLE,) of idleness,
Expand Down

0 comments on commit 646d921

Please sign in to comment.