Terminal confused after restarting script programmatically (Python) #21378

Open
opened 2026-01-31 07:42:58 +00:00 by claunia · 0 comments
Owner

Originally created by @sushantshah-dev on GitHub (Mar 10, 2024).

Windows Terminal version

1.19.10573.0

Windows build number

10.0.22621.3235

Other Software

Including but but not limited to VSCode terminal

Steps to reproduce

  1. Restart script using:
def check_file_changes(self):
        """
        Checks for file changes and reloads the server if any changes are detected.
        """
        for path, _, files in os.walk("."):
            for file in files:
                if file.endswith(".py") and os.path.getmtime(os.path.join(path, file)) > self.init_time:
                    self.logger.warning("File<%s> changed. Reloading server..." % file)
                    os.execv(sys.executable, [f'"{sys.executable}"'] + [f'"{arg}"' for arg in sys.argv])
  1. Take multiple inputs at start of the script

Screenshot 2024-03-06 170035

Expected Behavior

No response

Actual Behavior

Terminal confused about input

Another thing that happens when I reload is, I see the line for accepting commands (eg. "C:\Users\XXXX>") before my code output appears... Kind of like, the terminal hallucinates that the program is done running.

Originally created by @sushantshah-dev on GitHub (Mar 10, 2024). ### Windows Terminal version 1.19.10573.0 ### Windows build number 10.0.22621.3235 ### Other Software Including but but not limited to VSCode terminal ### Steps to reproduce 1. Restart script using: ``` def check_file_changes(self): """ Checks for file changes and reloads the server if any changes are detected. """ for path, _, files in os.walk("."): for file in files: if file.endswith(".py") and os.path.getmtime(os.path.join(path, file)) > self.init_time: self.logger.warning("File<%s> changed. Reloading server..." % file) os.execv(sys.executable, [f'"{sys.executable}"'] + [f'"{arg}"' for arg in sys.argv]) ``` 2. Take multiple inputs at start of the script ![Screenshot 2024-03-06 170035](https://github.com/microsoft/vscode/assets/103421781/359c153a-ee23-43e7-98e6-41852042460d) ### Expected Behavior _No response_ ### Actual Behavior Terminal confused about input Another thing that happens when I reload is, I see the line for accepting commands (eg. "C:\Users\XXXX>") before my code output appears... Kind of like, the terminal hallucinates that the program is done running.
claunia added the Resolution-By-DesignNeeds-TriageIssue-Bug labels 2026-01-31 07:42:59 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#21378