if ret == 0:
    print('%s: is alive' % ip)
else:
    print('%s: did not respond' % ip)
q.task_done()
for i in range(num_threads):
    worker = Thread(target=pinger, args=(i, queue))
worker.setDaemon(True)
worker.start()
for ip in ips:
    queue.put(ip)
queue.join()
Ping a site in Python?