Skip to content

VSCode MacOS Python Extension termios.tcsetattr hangs in debug mode #371

@kirkdthompson

Description

@kirkdthompson

VS Code About Info:
Version: 1.48.0
Commit: db40434f562994116e5b21c24015a2e40b2504e6
Date: 2020-08-13T08:03:27.059Z
Electron: 7.3.2
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Darwin x64 19.6.0

Python Extension ID: ms-python.python 2020.08.101144

Program to demonstrate issue:

# vscodeerr.py
# Program to demonstrate tcssetattr hang.
# 20200816:KDT - Original.

import sys
import termios
import atexit
from select import poll, POLLIN

old_term = None
fd = None

def setTerm() :
	global old_term, fd
	fd = sys.stdin.fileno()
	new_term = termios.tcgetattr(fd)
	old_term = termios.tcgetattr(fd)

	# New terminal setting unbuffered, no echo
	new_term[3] = (new_term[3] & ~termios.ICANON & ~termios.ECHO)
	termios.tcsetattr(fd, termios.TCSANOW, new_term)

	# Support normal-terminal reset at exit
	atexit.register(setNormal)
	
	p = poll()
	p.register(sys.stdin, POLLIN)

def setNormal() :
	termios.tcsetattr(fd, termios.TCSAFLUSH, old_term)

# main program
def main() :
	setTerm()
	print('All okay')

# Start, call main()
main()

Notes:

  1. VS Code running with Python extension installed, Python 3.8.3 installed and selected as interpreter.
  2. Code above as only python file.
  3. launch.js set to current python flle.
  4. RUN program result:
    python3 /Users/kirkthompson/Projects/PythonProjects/VSCodeErr/vscodeerr.py
    All okay
  5. DEBUG program result:
    Hangs at termios.tcsetattr(fd, termios.TCSANOW, new_term) line.
    Pressing Debug Stop button displays VS Code notification "timeout after 1000 ms"

I don't know exactly when VS Code and the extension were updated, but prior to this update, everything worked as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions