1
0

jsondb: raise an exception if a daemon thread attempts to write

This commit is contained in:
ThomasV
2023-09-28 18:28:29 +02:00
parent 71d6cc0b35
commit 98cecb305e
2 changed files with 3 additions and 5 deletions

View File

@@ -238,7 +238,7 @@ class QEDaemon(AuthMixin, QObject):
self._loading = False
self.loadingChanged.emit()
threading.Thread(target=load_wallet_task, daemon=True).start()
threading.Thread(target=load_wallet_task, daemon=False).start()
@pyqtSlot()
@pyqtSlot(str)

View File

@@ -391,8 +391,7 @@ class JsonDB(Logger):
@locked
def _append_pending_changes(self):
if threading.current_thread().daemon:
self.logger.warning('daemon thread cannot write db')
return
raise Exception('daemon thread cannot write db')
if not self.pending_changes:
self.logger.info('no pending changes')
return
@@ -405,8 +404,7 @@ class JsonDB(Logger):
@profiler
def _write(self):
if threading.current_thread().daemon:
self.logger.warning('daemon thread cannot write db')
return
raise Exception('daemon thread cannot write db')
if not self.modified():
return
json_str = self.dump(human_readable=not self.storage.is_encrypted())