fix: Adjust memory threshold for Discord message sending to enhance reliability

This commit is contained in:
Aaron 2025-11-15 13:15:45 -05:00
parent ce816af9e7
commit 621a48f011
2 changed files with 2 additions and 2 deletions

View File

@ -60,7 +60,7 @@ def send_discord_message(message, username="Auto Garden Bot", is_alert=False, de
# Quick mem check before importing urequests/SSL # Quick mem check before importing urequests/SSL
mem = getattr(gc, "mem_free", lambda: None)() mem = getattr(gc, "mem_free", lambda: None)()
# Require larger headroom based on device testing (adjust if you re-test) # Require larger headroom based on device testing (adjust if you re-test)
if mem is not None and mem < 105000: if mem is not None and mem < 95000:
print("Discord send skipped: ENOMEM ({} bytes free)".format(mem)) print("Discord send skipped: ENOMEM ({} bytes free)".format(mem))
return False return False

View File

@ -201,7 +201,7 @@ if wifi and wifi.isconnected():
gc.collect() gc.collect()
ram_free = gc.mem_free() ram_free = gc.mem_free()
print(f"DEBUG: Free RAM before Discord send: {ram_free // 1024} KB") print(f"DEBUG: Free RAM before Discord send: {ram_free // 1024} KB")
mem_ok = ram_free > 105000 mem_ok = ram_free > 95000
if mem_ok: if mem_ok:
ok = discord_webhook.send_discord_message("Pico W online at http://{}".format(ifconfig[0]), debug=False) ok = discord_webhook.send_discord_message("Pico W online at http://{}".format(ifconfig[0]), debug=False)
if ok: if ok: