The key is to start the thread using threading, not thread:
t1 = threading.Thread(target=my_function, args=())
t1.start()
Then use
z = t1.is_alive()
# Changed from t1.isAlive() based on comment. I guess it would depend on your version.
or
l = threading.enumerate()
You can also use join():
t1 = threading.Thread(target=my_function, args=())
t1.start()
t1.join()
# Will only get to here once t1 has returned.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…