diff --git a/back/src/app_video.py b/back/src/app_video.py index 8657536..b1d87f6 100755 --- a/back/src/app_video.py +++ b/back/src/app_video.py @@ -150,6 +150,9 @@ if __name__ == "__main__": debug.info("Start REST application: " + str(app.config['REST_HOST']) + ":" + str(app.config['REST_PORT'])) app.config.REQUEST_MAX_SIZE=10*1024*1024*1024 app.run(host=app.config['REST_HOST'], port=int(app.config['REST_PORT'])) + #app.stop() + debug.info("Sync all BDD ... (do not force stop ...)"); + data_global_elements.save_all_before_stop(); debug.info("END program"); sys.exit(0) diff --git a/back/src/data_global_elements.py b/back/src/data_global_elements.py index be84e46..c040392 100644 --- a/back/src/data_global_elements.py +++ b/back/src/data_global_elements.py @@ -24,11 +24,33 @@ def add_interface(_name, _interface): import time, threading -def check_save(): - print(time.ctime()) + +system_stop = False +system_counter = 0 + +def save_all(): + global system_counter + system_counter += 1 + if system_counter <= 10: + return + system_counter = 0 + for elem in interfaces.keys(): + if system_stop == True: + return + interfaces[elem].check_save() + +def save_all_before_stop(): + global system_stop + system_stop = True for elem in interfaces.keys(): interfaces[elem].check_save() - threading.Timer(10, check_save).start() + +def check_save(): + print(time.ctime()) + save_all() + if system_stop == True: + return + threading.Timer(1, check_save).start() check_save()