feat: adding support for saving the status of a DataService class

By passing a the "filename" keyword to the DataService init function,
one can save the state of the instance in this file. Quitting the service
(Ctrl+C) will dump the state of the instance in the file with given
filename. When starting the instance, it will load these values again.
This commit is contained in:
Mose Müller
2023-08-02 12:06:21 +02:00
parent a288c35c50
commit a9b98b675d
2 changed files with 63 additions and 2 deletions

View File

@ -173,6 +173,9 @@ class Server:
async def shutdown(self) -> None:
logger.info("Shutting down")
logger.info(f"Saving data to {self._service._filename}.")
self._service.write_to_file()
await self.__cancel_servers()
await self.__cancel_tasks()