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__':