I've got a program with a console menu. I use input() to, well, get user input. But when I want to force-restart/terminate program execution in PyCharm or close IDE entirely, the program keeps running until I enter anything.
This snippet is a stripped-down version:
while True:
inp = input()
if inp == 'hi':
print('hello there')
elif inp == 'exit':
break
else:
print('unknown command')
and prints out in console:
KeyboardInterrupt
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)
I've done some research:
But I think it's just a workaround, and I'd like to know more about why this is happening. Also have you encountered this before?
2021.2 PyCharm tries to gracefully terminate processes on Windows with WinP instead of killing them as it used to be. That's probably is a reasonable behavior - once you click "Stop" once Ctrl+C should be sent, the next click on "Stop" should kill the process. It works this way on Linux and macOS (SIGINT and SIGKILL). Unfortunately, the new behavior has a bug leading to a bunch of issues.
Try the following inside the IDE to revert to the old behavior
use.winp.for.graceful.process.terminationSee the relevant ticket in PyCharm's bug tracker:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With