1

I was curious if anyone had any insight to this error I am having. I have a program in python that run's an intro-animation using asciimatics. Following this animation, I attempt to get input from the user using input(), but get the following error -> RuntimeError: input(): lost sys.stdin. I know asciimatics has to take some control so sys.stdin/sys.stdout, and perhaps this is the root of the problem.

Animation

def demo(screen):
    scenes = []
    scenes.append(PlasmaScene(screen))
    screen.play(scenes, stop_on_resize=True, repeat=False)

def main():
    Screen.wrapper(demo)

Where it's called

clear()
animate_intro() # asciimatic animation
clear()

LOGGED, USER = login_entry(None) # input() called in 'login_entry()'

Error Thrown

RuntimeError: input(): lost sys.stdin
etchris
  • 33
  • 5
  • What operating system are you using? I'm guessing some variant of Windows because I don't see this when I test on Linux. – Peter Brittain Jan 15 '23 at 10:48
  • @PeterBrittain - good question and isomer int I had left out. Yes this is windows, windows 11. I can send a follow up here in a second once I get to my computer on how the error can be created – etchris Jan 16 '23 at 17:43
  • @PeterBrittain - Basically what happens is I have one program, `main.py`, that calls that animation `.py` file using the following `os.system("python animation.py")`. After the animation finishes we then get back to the main program. Then in the main program, I do another `os.system("python other_file.py")` which runs a different `.py` file that has `input()` in it. When this `input()` line is hit in the other file, the error is thrown. And has only happened after first calling/running `animation.py`. – etchris Jan 16 '23 at 18:27
  • Ok... I've just tried on Windows 10. No error. Are you running your code in an editor, the CMD command prompt or something else? – Peter Brittain Jan 16 '23 at 22:10
  • @PeterBrittain - I am running the program through a command prompt. Let me try to recreate the error and get a video spun up! – etchris Jan 16 '23 at 22:45
  • @PeterBrittain - you know what, I can seem to recreate the error anymore . . . odd, but also a good thing I suppose. I will keep tinkering to see if it can come about again. The only difference between now and when I made the initial post is I have since completely reset my laptop due to getting a virus on it . . . perhaps that solved the issue >:D. If I can get the issue to pop up again, I can talk to you through gitter! – etchris Jan 16 '23 at 23:10

1 Answers1

0

As discussed... This appears to be some complex interaction between asciimatics use of win32 and the cmd command prompt on windows.

It wasn't reproducible on my system, but using subprocess.run("python games/life.py") instead of os.system appears to have fixed it.

Peter Brittain
  • 13,489
  • 3
  • 41
  • 57