Skip to content

Commit

Permalink
pw_rpc: Add stop method to Watchdog
Browse files Browse the repository at this point in the history
Previously there was no way to stop a Watchdog from running
This resulted in endlessly-executing callbacks.

Fix: b/350822543
Change-Id: Ib16eeda2b6cf39f684052ae4b92805f935a483fe
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230692
Commit-Queue: Taylor Cramer <[email protected]>
Pigweed-Auto-Submit: Taylor Cramer <[email protected]>
Lint: Lint 🤖 <[email protected]>
Reviewed-by: Wyatt Hepler <[email protected]>
  • Loading branch information
cramertj authored and CQ Bot Account committed Aug 19, 2024
1 parent fbf120d commit 00582ec
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pw_rpc/py/pw_rpc/console_tools/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ def start(self) -> None:
self._watchdog.daemon = True
self._watchdog.start()

def stop(self) -> None:
"""Stops the watchdog.
This will not trigger the execution of any callbacks and will prevent
further execution of any callbacks (including `while_expired`) until
`start` is called again.
"""
self._watchdog.cancel()

def reset(self) -> bool:
"""Resets the timeout; calls the on_reset callback if expired.
Expand Down

0 comments on commit 00582ec

Please sign in to comment.