Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.99k stars 5.18k forks source link

tmc: Query latest value during _init_registers() #6406

Closed KevinOConnor closed 7 months ago

KevinOConnor commented 7 months ago

The set_register() code may block, and it therefore may be possible that the loop in _init_registers() could occur in parallel with other updates. That could result in a "OrderedDict mutated during iteration" error.

Avoid the error by querying the latest value during each iteration of the loop.

Error reported at https://klipper.discourse.group/t/unhandled-exception-during-run-z-hop/11580 and https://klipper.discourse.group/t/sensorless-homing-x-returns-unhandled-exception-during-run/9844

-Kevin