From aa078febc5b32eb4623a6e76b9bd05096646d910 Mon Sep 17 00:00:00 2001 From: marcsello Date: Thu, 24 Sep 2020 16:21:28 +0200 Subject: [PATCH] Added local minimum --- kebab_worker/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/kebab_worker/main.py b/kebab_worker/main.py index dc13a4b..c812962 100644 --- a/kebab_worker/main.py +++ b/kebab_worker/main.py @@ -55,9 +55,21 @@ def main(): p.start() processes.append(p) + local_best = 1000 + while True: result = outqueue.get() - requests.post(target_url, json=result) + result_score = len(result) + + if result_score < local_best: + print(f"New local best found: {local_best} -> {result_score}") + local_best = result_score + + try: + r = requests.post(target_url, json=result) + r.raise_for_status() + except (ConnectionError, requests.HTTPError) as e: + print(f"Error while posting result: {e}") if __name__ == '__main__':