From ef9cc51750b750fa3a6405a104160b8575efce10 Mon Sep 17 00:00:00 2001 From: Yashar Dabiran Date: Thu, 13 Feb 2025 21:23:02 -0500 Subject: [PATCH] Sleep for 60 seconds if an exception occurs to avoid spamming Bring servers --- main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 4564b10..83050dd 100644 --- a/main.py +++ b/main.py @@ -11,6 +11,8 @@ from bring_api.exceptions import BringException load_dotenv() +EXCEPTION_SLEEP_INTERVAL = 60 + class BringPlugin: SLEEP_INTERVAL = 15 * 60 # 15 minutes @@ -67,7 +69,9 @@ if __name__ == "__main__": loop.run_until_complete(bring_plugin.run()) except BringException as e: print(f"Bring exception occured: {e}") + print(f"Sleeping for {EXCEPTION_SLEEP_INTERVAL} seconds.") + time.sleep(EXCEPTION_SLEEP_INTERVAL) print(f"Retrying the service") except Exception as e: - print(f"Unknowne exception occured: {e}") + print(f"Unknown exception occured: {e}") raise \ No newline at end of file