Fix retained Life360 request tasks - #102
Conversation
|
Confirming this fix on a second platform. Thanks for running down the upstream CPython cause and writing the workaround — I could report the symptom, but the actual diagnosis and fix are yours. Environment: Home Assistant Green (aarch64), HA Core 2026.8.3, Python 3.14.6, Life360 0.10.2, one account, five trackers, 3.83 GB RAM. Same Python 3.14 runtime implicated in python/cpython#152569. Before the patch
HA Core RSS went 467 MB → 2,536 MB in roughly nine hours (~65 MB/hour). After applying this PRSwapped only
The residual Note on severityWorth flagging given the hardware difference: your LXC has 4 GiB and took ~57 hours to exhaust. A Home Assistant Green has 3.83 GB usable, no upgrade path, and reached the ceiling in about a day — after which the kernel SIGKILLs whatever container is largest. On this instance that repeatedly killed an unrelated add-on with no obvious connection to Life360, which is what made it hard to attribute in the first place. The Green is the appliance Home Assistant sells to non-technical users, so this likely bites hardest on the least-diagnosable setups. Follow-upThis instance is now running patched under normal household load. I'll post a 24-hour soak result tomorrow — neither of our tests so far has run long enough to show durability, only that retention stops. |
31-hour soak resultFollowing up on my earlier confirmation. Same instance — Home Assistant Green (aarch64), HA Core 2026.8.3, Python 3.14.6, Life360 0.10.2 with this PR's No restarts, no intervention, normal household load for 31 hours. Task retention
For comparison, the same instance before the patch held 246,124 live Tasks and was adding ~360 every 5 minutes. 96 total is normal for this instance. MemoryThat is ~6 MB/hour, against ~65 MB/hour before the patch — roughly an 11× reduction. The residual is not Life360. The only things growing in the profiler samples are Practical outcomeI had a memory-guard automation in place that restarts HA Core when RAM crosses 85%, because before the patch this box was hitting the ceiling roughly daily and the kernel would SIGKILL whatever container was largest. That automation has not fired once in 31 hours. Before the patch it would have fired at least once. Longest uninterrupted uptime this instance has had in weeks. Happy to keep it running and report again at a week if that is useful. |
Fixes #101.
What changed
Python 3.14 has an upstream
asyncio.wait(..., FIRST_COMPLETED)retention bug when many requests repeatedly wait against the same long-lived task: python/cpython#152569Life360 triggered that behavior by racing every client request against one account-lifetime failure task. This change keeps the shared failure event but replaces the shared task with a bounded watcher for each active request. The watcher is canceled and awaited when its request finishes.
The cancellation behavior is preserved when:
CancelledErrorand returns normally.Tests
18 passed, 2 xfailed.18 passed, 2 xfailed.I also tested the patch on Home Assistant Core 2026.8.3 with Life360 0.10.2. The original code retained 924 completed Life360
_request()tasks after about 5.5 minutes. With this patch, the same profiler check after six minutes found zero retained Life360 request tasks; all 10 entities remained available and memory stayed between 971.7 and 976.8 MiB with no swap use.