microsoft / microsoft/vscode-python-debugger

Prevent vscode from exiting the Python interpreter a script completes

Offen
#524 9 Kommentare 41 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

feature-request needs PR
Vorherrschende Sprache
TypeScript
Sterne
181
Forks
126
Ø Merge
2 T. 3 Std.
Gemergte PRs (30 T.)
3

Beschreibung

Discussed in https://github.com/microsoft/vscode-python/discussions/16082

Originally posted by larsoner April 29, 2021
The way I have used Python for years (through Spyder, directly from a bash terminal, etc.) is to execute a script in interactive mode such that once it's done, you can interact with it, e.g.:

python -i script.py

VSCode's debugger does not give a way to get this behavior currently. And it seems like I am not the only one looking for it:

One workaround is to put a breakpoint at the end of your file, but this requires extra work.

Another workaround is to add "env": {"PYTHONINSPECT": "true"}, to the launch configuration with integratedTerminal, but this doesn't work properly as any input is captured and newlines aren't treated properly while printing, which makes it pretty unusable.

I could see at least two potential solutions (the first would be better I think):

  1. Make it so that in PYTHONINSPECT mode, the terminal could be interacted with properly, possibly by adding a new inspectOnExit or something that ran in -i / PYTHONINSPECT mode and returned proper input/output when the script completes. Based on https://github.com/microsoft/vscode-python/issues/5497 it sounds like this is a no-go, though.
  2. Add a stopOnExit debug option to mirror stopOnEntry in the debugger. This way at least variables could be inspected using the vscode debugger.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Im Issue werden keine Implementierungsdateien oder Tests genannt. Beginne mit der Prüfung der verlinkten Diskussion und des bestehenden stopOnEntry-Debuggerverhaltens und vergleiche dann die vorgeschlagenen interaktiven Ansätze PYTHONINSPECT und stopOnExit mit Issue 5497. Done sollte eine nutzbare Inspektion nach der Skriptausführung ermöglichen, ohne einen Breakpoint am Ende zu erfordern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
devtools
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.