This can be called from the main thread to safely stop this thread. Note that it does not attempt to write out remaining history before exiting. That should be done by calling the HistoryManager's end_session method.
(self)
| 1176 | atexit.unregister(self.stop) |
| 1177 | |
| 1178 | def stop(self) -> None: |
| 1179 | """This can be called from the main thread to safely stop this thread. |
| 1180 | |
| 1181 | Note that it does not attempt to write out remaining history before |
| 1182 | exiting. That should be done by calling the HistoryManager's |
| 1183 | end_session method.""" |
| 1184 | if self._stopped: |
| 1185 | return |
| 1186 | self._stop_now = True |
| 1187 | |
| 1188 | self.save_flag.set() |
| 1189 | self._stopped = True |
| 1190 | if self.ident is not None and self != threading.current_thread(): |
| 1191 | self.join() |
| 1192 | |
| 1193 | def __del__(self) -> None: |
| 1194 | self.stop() |