Checking on a thread / remove from list
As TokenMacGuy says, you should use thread.is_alive()
to check if a thread is still running. To remove no longer running threads from your list you can use a list comprehension:
for t in my_threads: if not t.is_alive(): # get results from thread t.handled = Truemy_threads = [t for t in my_threads if not t.handled]
This avoids the problem of removing items from a list while iterating over it.
mythreads = threading.enumerate()
Enumerate returns a list of all Thread objects still alive.https://docs.python.org/3.6/library/threading.html