From c6bc1ebe636e7f6de6160cc8955cb31d88aec414 Mon Sep 17 00:00:00 2001 From: "Mr. Pennyworth" Date: Tue, 25 Jun 2024 20:36:15 -0500 Subject: [PATCH] Wait for meilisearch client to be healthy Fixes #28 --- info.plist | 2 +- pyapp/BetterDict.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/info.plist b/info.plist index 617da1f..12ab66e 100644 --- a/info.plist +++ b/info.plist @@ -974,7 +974,7 @@ Subsequent searches should be snappy variablesdontexport version - 0.2.12 + 0.2.13 webaddress https://github.com/mr-pennyworth/alfred-better-dictionaries diff --git a/pyapp/BetterDict.py b/pyapp/BetterDict.py index ce74f9b..8f4d41e 100644 --- a/pyapp/BetterDict.py +++ b/pyapp/BetterDict.py @@ -369,8 +369,11 @@ def search_client(db_path): if not is_search_server_up(): start_search_server(db_path) while not is_search_server_up(): - time.sleep(0.01) - return meilisearch.Client(f"http://{SEARCH_IP}:{SEARCH_PORT}") + time.sleep(0.1) + client = meilisearch.Client(f"http://{SEARCH_IP}:{SEARCH_PORT}") + while not client.is_healthy(): + time.sleep(0.1) + return client def create_index(dict_id, db_path):