Safe Async Boilerplate with WDT reset #18409
Replies: 4 comments
-
|
I don't think your friend chat has actually read "Peter async Hinch's" excellent documentation and tips . I suggest you do: |
Beta Was this translation helpful? Give feedback.
-
|
To add to the above :) async def wdt_feed():
while True:
wdt.feed()
await asyncio.sleep(1)If the program crashes or stops running then the WDT will time out and hard-reset the host. If you want to run checks on the running code you can do this in standard |
Beta Was this translation helpful? Give feedback.
-
|
Ok, thanks, asyncio is quite something to get into. The reason I would like an extra safeguard structure is that I have some background tasks that sometimes fail silently. If such a task fails, a single "async def wdt_feed()" would just keep running happily and feed the WDT. Until I have that figured out I would like to have a broad safeguarding system. Yeah, you might say it's like tearing out the kitchen because the sink leaks but I don't have my async plumbing license yet. Thanks |
Beta Was this translation helpful? Give feedback.
-
|
If I had a task that "sometimes fails silently" I'd want to know the reason. For example, it might fail to get a response from a particular hardware interface. In this case you'd devise a means of detecting this (e.g. using Simply accepting that something sometimes fails silently without determining the reason sounds like a very unsatisfactory approach.
There is a learning curve but tackling it is very worthwhile. In my experience the majority of professional firmware uses cooperative scheduling. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
So, lately I've been diving into async.
My goal is to use async but also to have code that recovers from unexpected errors by resetting using the WDT.
With the help of chatgpt I conconted this code. But chatgpt is well... chatgpt.
Chatgpt says it's all fine and dandy but I'm curious about some real human/programmers/expert feedback.
So if you have any feedback, please post it.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions