(self)
| 820 | |
| 821 | @needs_sqlite |
| 822 | def run(self): |
| 823 | # We need a separate db connection per thread: |
| 824 | try: |
| 825 | self.db = sqlite3.connect(self.history_manager.hist_file, |
| 826 | **self.history_manager.connection_options |
| 827 | ) |
| 828 | while True: |
| 829 | self.history_manager.save_flag.wait() |
| 830 | if self.stop_now: |
| 831 | self.db.close() |
| 832 | return |
| 833 | self.history_manager.save_flag.clear() |
| 834 | self.history_manager.writeout_cache(self.db) |
| 835 | except Exception as e: |
| 836 | print(("The history saving thread hit an unexpected error (%s)." |
| 837 | "History will not be written to the database.") % repr(e)) |
| 838 | |
| 839 | def stop(self): |
| 840 | """This can be called from the main thread to safely stop this thread. |
no test coverage detected