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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user