tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
2.99k stars 250 forks source link

Refactor HID write timeout logic #1621

Closed jdeanwallace closed 11 months ago

jdeanwallace commented 11 months ago

Related https://github.com/tiny-pilot/tinypilot/issues/1026

This PR moves the multiprocessing timeout logic to a separate execute module, along with other related classes. This change simplifies the hid.write module by stripping out multiprocessing details not directly related to writing to the HID interface.

Notes

  1. We've moved the following classes to the new execute module:
    • ProcessWithResult
    • ProcessResult
  2. We've moved the HID write timeout logic to a generic execute.with_timeout function
  3. We've moved hid.write_test.py to execute_test.py
  4. I'm not really sure why we need this function or if it is still required, but I kept it around anyway: https://github.com/tiny-pilot/tinypilot/blob/106e6448bd931da40f9e49c5fc97d5970fffa6d6/app/process.py#L84-L87

Peer testing

You can test this build by running the following command on a device:

curl \
  --silent \
  --show-error \
  --location \
  https://raw.githubusercontent.com/tiny-pilot/tinypilot/master/scripts/install-bundle | \
  sudo bash -s -- \
    https://output.circle-artifacts.com/output/job/5789b04e-8216-42fe-ad1e-227948464d03/artifacts/0/bundler/dist/tinypilot-community-20230907T1543Z-1.9.1-12+e1ba857.tgz

Review on CodeApprove

jdeanwallace commented 11 months ago
Automated comment from CodeApprove ➜

⏳ @mtlynch please review this Pull Request