(self, _interval, _callback)
| 141 | callback = None |
| 142 | |
| 143 | def __init__(self, _interval, _callback): |
| 144 | Thread.__init__(self, name="cleaner_db_thread") |
| 145 | self.interval = _interval * 60 |
| 146 | self.stop_flag = Event() |
| 147 | self.callback = _callback |
| 148 | self._cfg = Config.init() |
| 149 | |
| 150 | # We need to instantiate a new QsqlDatabase object with a unique name, |
| 151 | # because it's not thread safe: |
| 152 | # "A connection can only be used from within the thread that created it." |
| 153 | # https://doc.qt.io/qt-5/threads-modules.html#threads-and-the-sql-module |
| 154 | # The filename and type is the same, the one chosen by the user. |
| 155 | self.db = Database("db-cleaner-connection") |
| 156 | self.db_status, db_error = self.db.initialize( |
| 157 | dbtype=self._cfg.getInt(self._cfg.DEFAULT_DB_TYPE_KEY), |
| 158 | dbfile=self._cfg.getSettings(self._cfg.DEFAULT_DB_FILE_KEY), |
| 159 | dbjrnl_wal=self._cfg.getBool(self._cfg.DEFAULT_DB_JRNL_WAL) |
| 160 | ) |
| 161 | |
| 162 | def run(self): |
| 163 | if self.db_status == False: |
nothing calls this directly
no test coverage detected