Difference between exit() and sys.exit() in Python

 

Difference between exit() and sys.exit() in Python - Stack Overflow https://stackoverflow.com/questions/6501121/difference-between-exit-and-sys-exit-in-python

 

 

 

def ctrl_runtime():
if time.time() - ctrl_start >= max_script_time:
s = '%s%s%s%s%s' % ('程序开始执行时间', ctrl_start, '执行时间阈值', max_script_time, '终止执行')
logging.info(s)
print(s)
sys.exit(s)






def ctrl_runtime(exit_type=''):
if time.time() - ctrl_start >= max_script_time:
s = '%s%s%s%s%s%s%s%s%s' % (
'程序开始执行时间', ctrl_start, '执行时间阈值', max_script_time, '终止执行', ' exit_type =', exit_type, ' threadID ',
threading.get_ident())
logging.info(s)
if exit_type == '':
exit(s)
elif exit_type == 'sys':
sys.exit(s)
elif exit_type == 'os':
# an integer is required
# Required argument 'status' (pos 1) not found
os._exit(-1024)








Sat, 02 Dec 2017 15:55:55 chk_url_status_ordertab_notexpire.py[line:84] INFO DB (2003, "Can't connect to MySQL server on 'rm-xyz.mysql.xyz.acom.com' (timed out)")[thread:139775600219904][process:8191]
Sat, 02 Dec 2017 15:56:31 chk_url_status_ordertab_notexpire.py[line:84] INFO DB (2003, "Can't connect to MySQL server on 'rm-xyz.mysql.xyz.acom.com' (timed out)")[thread:139775029778176][process:8191]
Sat, 02 Dec 2017 15:59:20 chk_url_status_ordertab_notexpire.py[line:185] ERROR 20171202 15:58:29 threadID 139775080134400www.abc.cn/info/35028470.html DB Exception- (2003, "Can't connect to MySQL server on 'rm-xyz.mysql.xyz.acom.com' (timed out)")[thread:139775080134400][process:8191]
Sat, 02 Dec 2017 16:04:36 chk_url_status_ordertab_notexpire.py[line:84] INFO DB (2003, "Can't connect to MySQL server on 'rm-xyz.mysql.xyz.acom.com' (timed out)")[thread:139774509692672][process:8191]
Sat, 02 Dec 2017 16:16:33 chk_url_status_ordertab_notexpire.py[line:84] INFO DB (2003, "Can't connect to MySQL server on 'rm-xyz.mysql.xyz.acom.com' (timed out)")[thread:139773964429056][process:8191]

 

 

 

Sat, 02 Dec 2017 18:16:53 chk_url_status_ordertab_notexpire.py[line:46] INFO 程序开始执行时间1512205940.803967执行时间阈值3600终止执行 exit_type =os threadID 140530566547200[thread:140530566547200][process:31060]

 

 

您在 /var/spool/mail/root 中有邮件

 

From root@hadoop1.localdomain Sat Dec 2 17:22:41 2017
Return-Path: <root@hadoop1.localdomain>
X-Original-To: root
Delivered-To: root@hadoop1.localdomain
Received: by hadoop1.localdomain (Postfix, from userid 0)
id 80D294FC113C; Sat, 2 Dec 2017 17:22:41 +0800 (CST)
From: "(Cron Daemon)" <root@hadoop1.localdomain>
To: root@hadoop1.localdomain
Subject: Cron <root@hadoop1> python /home/data/crontab_chk_url/personas/trunk/plugins/spider/chk_url_status.py &> /dev/null
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
Precedence: bulk
X-Cron-Env: <XDG_SESSION_ID=725>
X-Cron-Env: <XDG_RUNTIME_DIR=/run/user/0>
X-Cron-Env: <LANG=zh_CN.UTF-8>
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=root>
X-Cron-Env: <USER=root>
Message-Id: <20171202092241.80D294FC113C@hadoop1.localdomain>
Date: Sat, 2 Dec 2017 17:22:41 +0800 (CST)

/bin/sh: 行 1: 7295 已终止 python /home/data/crontab_chk_url/personas/trunk/plugins/spider/chk_url_status.py &>/dev/null

 



 

posted @ 2017-12-02 16:50  papering  阅读(348)  评论(0编辑  收藏  举报