handle
This commit is contained in:
parent
438587e260
commit
9ed547c701
1 changed files with 5 additions and 1 deletions
|
@ -26,7 +26,7 @@ HEADERS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Define a maximum number of retry attempts and a delay between retries
|
# Define a maximum number of retry attempts and a delay between retries
|
||||||
MAX_RETRY_ATTEMPTS = 3
|
MAX_RETRY_ATTEMPTS = 5 # Changed to 5
|
||||||
RETRY_DELAY_SECONDS = 10
|
RETRY_DELAY_SECONDS = 10
|
||||||
|
|
||||||
def handle_log_msg(prefix, value):
|
def handle_log_msg(prefix, value):
|
||||||
|
@ -45,6 +45,10 @@ def send_http_request_with_retry(url, data, headers):
|
||||||
elif reader_info.get("mode") == "TOGGLE":
|
elif reader_info.get("mode") == "TOGGLE":
|
||||||
ser.write("toggle".encode('utf-8'))
|
ser.write("toggle".encode('utf-8'))
|
||||||
break # Successful request, no need to retry
|
break # Successful request, no need to retry
|
||||||
|
elif response.status_code in [400, 401, 500]:
|
||||||
|
# Don't retry on certain errors
|
||||||
|
print(f"HTTP POST request failed with status code {response.status_code}. Not retrying.")
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
print(f"Failed to send FULL_CARD_ID via HTTP POST. Status code: {response.status_code}")
|
print(f"Failed to send FULL_CARD_ID via HTTP POST. Status code: {response.status_code}")
|
||||||
print(response.text)
|
print(response.text)
|
||||||
|
|
Loading…
Reference in a new issue