Optimization found by Claude in Display configuration. #408
martinHkristensen-cpu
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I will let him speak for himself :-) It was done on latest update.
Bug report & fix: File descriptor leak + UI latency in display_connector
Environment
Issue 1: File descriptor leak in
_try_connect_on_different_baudrates(nextion library)Severity: High — causes service degradation and eventual failure without reboot
Root cause:
The
nextionlibrary's_try_connect_on_different_baudrates()iterates through 8 baudrates on every connect/reconnect attempt. Each failed attempt opens a serial port file descriptor that is not properly closed on failure. This leaks ~8 fd's per reconnect cycle.Over time this produces:
...causing all subsequent connect attempts to fail silently, the display to go unresponsive, and elevated CPU load + SoC temperature from the continuous retry loop.
Observed fd growth: ~44 open fd's after 45 minutes of idle (baseline should be ~19)
Fix:
Override
_get_priority_ordered_baudrates()inTJCClientinsrc/tjc.pyto only attempt the correct baudrate for TJC displays:Result: fd count stable at ~19 baseline. Display remains responsive indefinitely without reboot.
Issue 2: Unnecessary 50ms delay per display command in
communicator.pySeverity: Medium — causes UI sluggishness under normal operation
Root cause:
_update_data_leaf()has a hardcodedasyncio.sleep(0.05)after every single write command. During a typical status update (temperature, position, speed, progress etc.) this introduces hundreds of milliseconds of artificial delay that accumulates in the async queue.Fix: Remove the sleep entirely. The asyncio event loop handles cooperative scheduling without it.
Also reduce
navigate_tosettle time from 250ms to 100ms — sufficient for TJC page transitions:Issue 3: Unguarded
self.data_mappingattribute access inupdate_data()Severity: Low — defensive fix
update_data()falls back toself.data_mappingwith no guard, producing an unhelpfulAttributeErrorif the attribute is not set on the subclass.Fix:
Files changed:
src/tjc.py— add_get_priority_ordered_baudrates()override toTJCClientsrc/communicator.py— removeasyncio.sleep(0.05), reducenavigate_tosettle time, guarddata_mappingBeta Was this translation helpful? Give feedback.
All reactions