summaryrefslogtreecommitdiff
path: root/shared-module/network
diff options
context:
space:
mode:
authorSean Cross <sean@xobs.io>2020-05-27 10:21:43 +0800
committerSean Cross <sean@xobs.io>2020-05-27 11:28:50 +0800
commitdbf1bef56ab3a7ce73388c9833c9aa5a4074eb24 (patch)
tree475977568c19a41451c9dee09e9a494405f9272a /shared-module/network
parente470376c126828c768dfbcf25430869e8bc2b021 (diff)
watchdog: support catching the timeout
With this patch, the exception can now be caught: import microcontroller import watchdog import time wdt = microcontroller.watchdog wdt.timeout = 5 while True: wdt.mode = watchdog.WatchDogMode.RAISE print("Starting loop -- should exit after five seconds") try: while True: time.sleep(10) # pass # This also works for a spinloop except watchdog.WatchDogTimeout as e: print("Watchdog Expired (PASS)") except Exception as e: print("Other exception (FAIL)") print("Exited loop") This prints: Starting loop -- should exit after five seconds Watchdog Expired (PASS) Starting loop -- should exit after five seconds Watchdog Expired (PASS) Starting loop -- should exit after five seconds Watchdog Expired (PASS) Signed-off-by: Sean Cross <sean@xobs.io>
Diffstat (limited to 'shared-module/network')
0 files changed, 0 insertions, 0 deletions