Skip to content

Commit

Permalink
Reduce CPU usage of chip-console (#25663)
Browse files Browse the repository at this point in the history
This is busy polling the serial port, and as a result uses 100% CPU.
Use a non-zero timeout to avoid this.

Using asyncio would be better, but pyserial support for this is still
experimental.
  • Loading branch information
mspang authored and pull[bot] committed Nov 4, 2023
1 parent 2b3e93e commit 1039104
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/common/pigweed/rpc_console/py/chip_rpc/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ def console(device: str, baudrate: int,
serial_impl = SerialWithLogging

if socket_addr is None:
serial_device = serial_impl(device, baudrate, timeout=0)
serial_device = serial_impl(device, baudrate, timeout=0.1)
def read(): return serial_device.read(8192)
write = serial_device.write
else:
Expand Down

0 comments on commit 1039104

Please sign in to comment.