WebHost: move atexit saving to end of room hosting function (#3339)

This commit is contained in:
Fabian Dill
2024-05-19 18:25:56 +02:00
committed by GitHub
parent d3f4ee4994
commit e97eddcdaf
2 changed files with 6 additions and 4 deletions

View File

@@ -508,7 +508,7 @@ class Context:
self.logger.exception(e)
self._start_async_saving()
def _start_async_saving(self):
def _start_async_saving(self, atexit_save: bool = True):
if not self.auto_saver_thread:
def save_regularly():
# time.time() is platform dependent, so using the expensive datetime method instead
@@ -532,8 +532,9 @@ class Context:
self.auto_saver_thread = threading.Thread(target=save_regularly, daemon=True)
self.auto_saver_thread.start()
import atexit
atexit.register(self._save, True) # make sure we save on exit too
if atexit_save:
import atexit
atexit.register(self._save, True) # make sure we save on exit too
def get_save(self) -> dict:
self.recheck_hints()