Skip to content

Commit

Permalink
Fix microsoft#108: Debugger freezes in VSCode
Browse files Browse the repository at this point in the history
When talking DAP over stdio, disable stderr before logging anything to it.
  • Loading branch information
int19h committed Apr 8, 2020
1 parent 2ff3c11 commit 119d5ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/debugpy/adapter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@


def main(args):
# If we're talking DAP over stdio, stderr is not guaranteed to be read from,
# so disable it to avoid the pipe filling and locking up. This must be done
# as early as possible, before the logging module starts writing to it.
if args.port is None:
sys.stderr = open(os.devnull, "w")

from debugpy import adapter
from debugpy.common import compat, log, sockets
from debugpy.adapter import clients, servers, sessions
Expand Down
1 change: 0 additions & 1 deletion src/debugpy/adapter/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def __init__(self, sock):
# that are going to be used for DAP communication from now on.
sys.stdin = open(os.devnull, "r")
sys.stdout = open(os.devnull, "w")
sys.stderr = open(os.devnull, "w")
else:
stream = messaging.JsonIOStream.from_socket(sock)

Expand Down

0 comments on commit 119d5ca

Please sign in to comment.