I am using the python threading module for the first time and this is what I am trying to find out -- can we save and load state of python thread object in some database or file? Let's say I have the below piece of code in a program (this program runs like a server using python twisted) to do something asynchronously (like copying files in a non-blocking fashion).
def foo():
print('Hello world!')
import threading
thr = threading.Thread(target=foo, args=(), kwargs={})
thr.start()
Now, I don't do thr.join() here as I don't want to wait for the thread to complete. Now, is it even possible to save the state of thread or object and later retrieve it and find out if the thread is still alive or not? I can get the thread id and status by doing this but only through the thread object.
# thr.ident
# check status of thread by doing thr.is_alive()
I may be completely wrong here - but is it possible to save/load thread objects? Also, looking for suggestions. Thanks a lot!