I'm trying to make threaded flight software for a project in Python 3.4, in which I need threads to restart themselves in case an I/O error occurs during a sensor read or another fluke crash like that. Therefore I am working on making a watchdog to check if threads have died and restarting them.
At first I attempted to just check if the thread was no longer alive and restart it, which did this:
>>> if not a_thread.isAlive():
... a_thread.start()
Traceback (most recent call last):
File "", line 2, in
File "c:\Python34\lib\threading.py", line 847, in start
raise RuntimeError("threads can only be started once")
RuntimeError: threads can only be started once
This behaviour makes sense from the standpoint of threadingand Python itself, but makes my job harder. So I implemented a solution using