In this script:
import threading, socket
class send(threading.Thread):
def run(self):
try:
while True:
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((url,port))
s.send(b"Hello world!")
print ("Request Sent!")
except:
s.close()
except KeyboardInterrupt:
# here i'd like to kill all threads if possible
for x in range(800):
send().start()
Is it possible to kill all threads in the except of KeyboardInterrupt? I've searched on the net and yeah, I know that it has been already asked, but I'm really new in python and I didn't get so well the method of these other question asked on stack.