def loading_config():
try:
ts = DBconfig.RUN_TIME
while True:
i=0
while DBconfig.DBS[i]:
head = DBconfig.DBS[i][0]
print '-----HOST :',head[:3],'------------------------'
dhost = DBconfig.DBS[i][0]
dport = DBconfig.DBS[i][1]
duser = DBconfig.DBS[i][2]
dpass = DBconfig.DBS[i][3]
ddb = DBconfig.DBS[i][4]
create_mysql(dhost,dport,duser,dpass,ddb,head)
main_function(dhost,dport,duser,dpass,ddb,head)
print '-----US-time:',time.ctime(),'---'
i +=1
time.sleep(ts)
except Exception,e:
print 'loading_config error!',e
贴上代码那一刻,突然发现自己好蠢.....
已解决:
def loading_config():
ts = DBconfig.RUN_TIME
while True:
i=0
while DBconfig.DBS[i]:
head = DBconfig.DBS[i][0]
print '-----HOST :',head[:3],'------------------------'
dhost = DBconfig.DBS[i][0]
dport = DBconfig.DBS[i][1]
duser = DBconfig.DBS[i][2]
dpass = DBconfig.DBS[i][3]
ddb = DBconfig.DBS[i][4]
try:
create_mysql(dhost,dport,duser,dpass,ddb,head)
main_function(dhost,dport,duser,dpass,ddb,head)
except Exception,e:
print 'loading_config error'
print e
print '-----US-time:',time.ctime(),'---'
i +=1
time.sleep(ts)
不过回到最初的代码,好像只要异常发生就不能继续循环了?无解吗....
1
knightdf 2016-05-26 22:32:07 +08:00
catch and then continue
|
2
msg7086 2016-05-27 10:00:55 +08:00
你 catch 在最外层,当然会被你跳出循环了
|
3
kideny 2016-05-27 13:47:01 +08:00
这应该有很多种写法吧!
|