threading.enumerateで生存中のThreadオブジェクト全てのリストを取得できます。
import logging
import threading
import time
logging.basicConfig(level=logging.DEBUG, format='%(threadName)s: %(message)s')
def worker1():
logging.debug('start')
time.sleep(5)
logging.debug('end')
if __name__ == '__main__':
#threads = []
for _ in range(5):
t = threading.Thread(target=worker1)
t.setDaemon(True)
t.start()
#threads.append(t)
for thread in threading.enumerate():
if thread is threading.currentThread():
print(thread)
continue
thread.join()
Thread-1: start
Thread-2: start
Thread-3: start
Thread-4: start
Thread-5: start
<_MainThread(MainThread, started 4599717312)>
Thread-1: end
Thread-2: end
Thread-5: end
Thread-4: end
Thread-3: end