fix led-matrix-viz: use select.poll() instead of settimeout, fix hang

The O_NONBLOCK flag set by setblocking(False) was not cleared by
settimeout(n) on this CPython/kernel combo, causing recvfrom to never
return data. Switched to explicit select.poll() with frame-interval
based timeout — simpler, more portable, and avoids the O_NONBLOCK trap.

Also fixes midi-bridge: add time.sleep(0.01) in no-data paths to
prevent 100% CPU spin from spurious POLLIN on f_midi rawmidi.
This commit is contained in:
2026-06-23 00:34:33 -07:00
parent dbd7c2cece
commit f1b65eb4d9
2 changed files with 37 additions and 26 deletions
+2
View File
@@ -75,6 +75,8 @@ def main():
elif len(buf) >= 2 and (buf[0] & 0xE0) in (0xC0, 0xD0):
_flush(sock, buf)
buf = bytearray()
if not events:
time.sleep(0.01)
except OSError as e:
if e.errno == 19:
os.close(fd)