Open dkozel opened 4 years ago
For the note about gracefully ending an observation in the middle I found this which looks reasonable, but I don't know if we need to make the entire thread class or can just use some of the ideas in the trackscan_obs function. This is mostly a note to myself.
import threading
class StoppableThread(threading.Thread):
"""Thread class with a stop() method. The thread itself has to check
regularly for the stopped() condition."""
def __init__(self, *args, **kwargs):
super(StoppableThread, self).__init__(*args, **kwargs)
self._stop_event = threading.Event()
def stop(self):
self._stop_event.set()
def stopped(self):
return self._stop_event.is_set()
The responsibility for running the observation lives with the individual observation blocks. This includes handling the timing between steps. Here's an example (pseudo Python) of how to launch a thread when the flowgraph starts to do this.