fix: Adjust memory thresholds for Discord message sending to match device capabilities
This commit is contained in:
parent
c6f46e097b
commit
4400fb5a74
@ -56,8 +56,8 @@ def send_discord_message(message, username="Auto Garden Bot", is_alert=False):
|
|||||||
# 1b) quick mem check - avoid importing urequests/TLS when too low
|
# 1b) quick mem check - avoid importing urequests/TLS when too low
|
||||||
try:
|
try:
|
||||||
mem = getattr(gc, "mem_free", lambda: None)()
|
mem = getattr(gc, "mem_free", lambda: None)()
|
||||||
# raised threshold to reduce chance of spike during TLS/requests
|
# lower threshold to match this board's free heap (~100 KB observed)
|
||||||
if mem is not None and mem < 140000:
|
if mem is not None and mem < 90000:
|
||||||
return False
|
return False
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|||||||
2
main.py
2
main.py
@ -408,7 +408,7 @@ while True:
|
|||||||
_gc.collect()
|
_gc.collect()
|
||||||
_gc.collect()
|
_gc.collect()
|
||||||
# require a conservative free memory threshold before TLS (adjust to your device)
|
# require a conservative free memory threshold before TLS (adjust to your device)
|
||||||
mem_ok = getattr(_gc, 'mem_free', lambda: 0)() > 140000
|
mem_ok = getattr(_gc, 'mem_free', lambda: 0)() > 90000
|
||||||
if mem_ok:
|
if mem_ok:
|
||||||
try:
|
try:
|
||||||
ok = discord_webhook.send_discord_message(pending_discord_message)
|
ok = discord_webhook.send_discord_message(pending_discord_message)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user