How to track "the fall" of the script?

Good afternoon.

Written a small script that periodically parses the web-page. "Demonized" is the script using this class: Source.
The script itself works correctly, but it sometimes "falls". And can work consistently for two months and "fall", and maybe a week.

Using the library logging script writes its log. It was determined that the crash occurred after this code:
while True:
 except Exception as error:
 logging.error("Error while getting updated pages: %s", error)
else:"Output list: %s",'//pre')[0].text())

I thought that the problem with getting the updated pages, but it is correct. According to the log it is visible that triggered the block else. After the script stops. After this block is another entry in the log, but it is not recorded.
Running it all on CentOS 6.7 (Final). The script is written in python3, python version 3.4.3, a library is used Grab.

Tell me how to track which "crashes" the script? Maybe the Python is a common log or in the system somewhere it can be tracked?
June 10th 19 at 16:27
3 answers
June 10th 19 at 16:29
Generally when working with demons is done in the following diagram.
1. Any demon when you start to write its PID into a file and running.
2. The cron, say every 5 seconds, run Manager, which reads the file(s) with the recorded PID and checks whether the process is alive. If the process is alive, then the Manager terminates. If the process has died, he picks up a demon, and terminates.
Thanks for the reply. I will try to implement. - zoila commented on June 10th 19 at 16:32
Generally there are already ready solutions. For one demon, they are certainly excessive, but if you have a whole farm of demons, then to invent anything not necessary. - Roderick92 commented on June 10th 19 at 16:35
thank you. Made a bash script to check and hung on the crowns.
When I wrote this parser read about supervisor, but did not use it thinking that class would be sufficient(which is in question pointed out). - zoila commented on June 10th 19 at 16:38
June 10th 19 at 16:31
Do not use while use

One can use systemd-run to create the transient .timer units. That is, one can set a command to run at a specified time without having a service file. For example the following command touches a file after 30 seconds:
# systemd-run --on-active=30 /bin/touch /tmp/foo
June 10th 19 at 16:33
. According to the log it is visible, that triggers the else block. After the script stops

Well, you in else is a break that can exit the loop, all right. If it falls further, put a try catch recording in log, or just write down somewhere the output of the program (python3 &> file.using log or supervisor for example)
Given the cycle is not the demon, so the break statement allows to exit on successful execution and continue on. - zoila commented on June 10th 19 at 16:36
then why not give all the code? - Roderick92 commented on June 10th 19 at 16:39

Find more questions by tags Python