-
-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Hi Team,
We upgraded pywinpty from 2.x to 3.x and we're facing issue in reading and writing to the process. It is behaving weird.
I've added a sample code to test both versions, which works fine in 2.x. I'm not sure what is wrong. I've also attached a video to demo the issue.
Screen.Recording.2025-10-09.at.11.21.29.mov
import winpty
import threading
import time
def reader(proc):
while True:
try:
data = proc.read(1024) # returns a string in 3.0.2
if not data:
break
print(data, end='', flush=True)
except EOFError:
break
def send_string_char_by_char(proc, s, delay=0.05):
for ch in s:
proc.write(ch)
time.sleep(delay)
def main():
proc = winpty.PtyProcess.spawn("cmd.exe")
t = threading.Thread(target=reader, args=(proc,), daemon=True)
t.start()
command = "echo Hello from winpty 3.0.2\r\n"
send_string_char_by_char(proc, command, delay=0.03)
time.sleep(1)
proc.write("exit\r\n")
t.join()
if __name__ == "__main__":
main()Metadata
Metadata
Assignees
Labels
No labels