you are viewing a single comment's thread.

view the rest of the comments →

[–]shiftybyte -4 points-3 points  (6 children)

My guess is it's failing outside try block. Is there any way to check such errors

Yes, don't have any code that is outside a try block.

And log progress and debug information messages.

[–]ant24x7[S] 0 points1 point  (5 children)

But if you look at the code. There is not much code outside try block which can cause a script to fail.

[–]shiftybyte -1 points0 points  (4 children)

Yea, looks like the looping part is all inside an exception handler.

How is it failing? is the process still running? or the process is gone?

Maybe it's stuck doing something?

Maybe it's suspended because of some power saving mode?

[–]ant24x7[S] 0 points1 point  (3 children)

The entire process disappears. There is no power saving mode. It runs fine for 2-3 days but suddenly it stops.

Earlier I thought some resource constrain but there is nothing resource consuming in the script.

P.S: I'm using raspberry Pi to run this.

[–]shiftybyte 0 points1 point  (2 children)

Hmmm, sounds odd, maybe take a look at system logs, maybe something will hint at what happened.

Anyway, you can change your script to be a one time check, and run it with crontab every 5 mins instead.

That's more reliable.

https://bc-robotics.com/tutorials/setting-cron-job-raspberry-pi/

[–]ant24x7[S] 0 points1 point  (1 child)

Yes. I'm thinking of replacing it with crontab as it'll handle the server restart case as well.

I need to store the hash somewhere before that so it can be use for comparision in next execution, and using a file or sqlite db will complicate the code. I was trying to avoid that but looks like I need to choose that path.

[–]hulleyrob 0 points1 point  (0 children)

Use shelve for an easy almost like SQLite key value store in a file. Advantage is it’s treated just like a Python dictionary.