fix recursion error mess

This commit is contained in:
Mathieu Broillet 2024-08-01 11:47:01 +02:00
parent a4d297fc33
commit d81d955a8b
Signed by: mathieu
GPG Key ID: C4A6176ABC6B2DFC

View File

@ -75,7 +75,9 @@ config = json.dumps(JSON_CONFIG)
def start_backend_loop(): def start_backend_loop():
global counter global counter, boot_time
while True:
load_engine() load_engine()
# loop for about an hour or 3000 requests then reload the engine (fix for trial license) # loop for about an hour or 3000 requests then reload the engine (fix for trial license)
@ -86,10 +88,13 @@ def start_backend_loop():
unload_engine() # just in case unload_engine() # just in case
load_engine() load_engine()
sleep(1) time.sleep(1)
unload_engine() unload_engine()
start_backend_loop()
# Reset counter and boot_time to restart the loop
counter = 0
boot_time = time.time()
def is_engine_loaded(): def is_engine_loaded():
@ -282,8 +287,8 @@ def find_best_plate_with_split(image: Image, grid_size: int = None, wanted_cells
if __name__ == '__main__': if __name__ == '__main__':
engine = threading.Thread(target=start_backend_loop, daemon=True) engine_thread = threading.Thread(target=start_backend_loop, daemon=True)
engine.start() engine_thread.start()
app = create_rest_server_flask() app = create_rest_server_flask()
app.run(host='0.0.0.0', port=5000) app.run(host='0.0.0.0', port=5000)