无法使用socket.accept终止进程

我正在Windows 10上用Python 3.8编写一个简单的python代理

If I use socket.accept I cannot terminate the process from console neither of these work: ctrl+c, ctrl+z, ctrl+d, break, ctrl+break, only closing the terminal.

I found in the docs this PIP https://www.python.org/dev/peps/pep-0475/ that is about retrying system calls on interrupts. I believe this is the reason why I cannot terminate the app.

不幸的是(很抱歉),但是这个写得非常出色的PIP并不在乎告诉实际如何取消系统调用。

Can anyone tell me a best practice how to terminate an app with a blocking socket.accept

提前致谢

我的代码:

import socket
import threading

bind_ip = "127.0.0.1"
bind_port = 9999

server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind((bind_ip, bind_port))

server.listen(5)

print("[*] Listening on {}:{}".format(bind_ip, bind_port))

def handle_client(client_socket):
    request = client_socket.recv(1024)

    print("received: " + request.decode('ascii'))

    client_socket.send("ACK".encode('ascii'))
    client_socket.close()

while True:
    client, addr = server.accept()

    print("[*] accepted {}:{}".format(addr[0], addr[1]))
    client_handler = threading.Thread(target=handle_client, args=(client,))
    client_handler.start()