When I run this script from my windows10 terminal:
import time
try:
while True:
time.sleep(1)
print('still alive')
except KeyboardInterrupt:
print('Keyboard interruption. Goodbye')
and press ctrl-c : keyboard interruptpion is activate and the process ends
but when I run this script:
import socket
try:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(('127.0.0.1', 65432))
s.listen()
conn, addr = s.accept()
except KeyboardInterrupt:
print('Keyboard interruption. Goodbye')
then crtl-c doesn't work and I need to find another way to shutdown my process. Why is that?