jim800121chen a6a121ae86 fix(local-tool): suppress KneronPLUS DeviceGroup.__del__ access violation
Windows 上 bridge script 結束時 Python GC 呼叫 DeviceGroup.__del__ →
kp_disconnect_devices 對已釋放的 native handle 操作 → OSError: access
violation reading 0x00...0C。這是 KneronPLUS SDK 的 destructor 沒做
null check 的已知問題,不影響功能但會印嚇人的 stack trace 到 stderr。

修法:
- 新增 _cleanup() 函式:明確 kp.core.disconnect_devices + 把
  _device_group 設 None(讓 __del__ 成 no-op)
- atexit.register(_cleanup) 確保 interpreter 關閉前 cleanup
- main() return 後也同步呼叫一次(belt-and-suspenders)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 15:40:30 +08:00
..