简体   繁体   中英

How to debug 'detected unhandled Python exception in' /var/log/messages

I have a python script checking status of my web service schedules for let's say 2000 times. One check takes like 5 minutes so the script execution takes like 2000x5 minutes.

I have application logs set up by logger and my system logs just to log information what is going on while script is running. However, script stops from some reasons. There is no single entry in my customized logs. The only thing I can find is

less /var/log/messages


 cat /var/log/messages | grep --color "pycharm.py"
Mar 27 08:48:48 hostname python: detected unhandled Python exception in 'pycharm.py'
Mar 30 13:58:16 hostname python: detected unhandled Python exception in 'pycharm.py'
Mar 31 08:22:01 hostname python: detected unhandled Python exception in 'pycharm.py'
Apr  1 05:42:09 hostname python: detected unhandled Python exception in 'pycharm.py'
Apr  2 03:04:16 hostname python: detected unhandled Python exception in 'pycharm.py'

The environment is Red Hat 7.2

Can anyone suggest to add some lines to script to chatch errors.

Things like do not give me anything.

try: 
   command
except:
   smth

You should log the unhandled exception as well as its stack trace, so you know what when wrong and where.

Use logger.exception() to log the exception content and stack trace.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM