python - Threads not exiting and program won't exit -


using script below, cannot seem exit threads. script runs smoothly without issues never exits when done. can still see thread alive, have use htop kill them or exit command line.

how can script exit , threads die?

def async_dns():     s = adns.init()     while true:         dname = q.get()         response = s.synchronous(dname,adns.rr.ns)[0]         if response == 0:             dot_net.append("y")             print(dname + ", y")         elif response == 300 or response == 30 or response == 60:             dot_net.append("n")             print(dname + ", n")         elif q.empty() == true:             q.task_done()  q = queue.queue() threads = [] in range(20):     t = threading.thread(target=async_dns)     threads.append(t)     t.start()  name in names:     q.put_nowait(name) 

remove , return item queue. if optional args block true , timeout none (the default), block if necessary until item available. if timeout positive number, blocks @ timeout seconds , raises empty exception if no item available within time. otherwise (block false), return item if 1 available, else raise empty exception (timeout ignored in case).

remember check queue.

see document of queue.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -