所以
所讨论的代码如下,但是它也可以在其他脚本上随机发生(我认为错误不在代码中)
出于某种原因,完全随机的它有时会崩溃并弹出“pythonw.exe已经停止工作”它可能在5小时、24小时或5天后。。。我搞不懂它为什么会崩溃。from datetime import date, timedelta
from sched import scheduler
from time import time, sleep, strftime
import random
import traceback
s = scheduler(time, sleep)
random.seed()
def periodically(runtime, intsmall, intlarge, function):
currenttime = strftime('%H:%M:%S')
with open('eod.txt') as o:
eod = o.read().strip()
if eod == "1":
EOD_T = True
else:
EOD_T = False
while currenttime >= '23:40:00' and currenttime <= '23:59:59' or currenttime >= '00:00:00' and currenttime <= '11:30:00' or EOD_T:
if currenttime >= '23:50:00' and currenttime <= '23:59:59':
EOD_T = False
currenttime = strftime('%H:%M:%S')
print currenttime, "Idling..."
sleep(10)
open("tca.txt", 'w').close
open("tca.txt", 'w').close
runtime += random.randrange(intsmall, intlarge)
s.enter(runtime, 1, function, ())
s.run()
def execute_subscripts():
st = time()
print "Running..."
try:
with open('main.csv'):
CSVFile = True
except IOError:
CSVFile = False
with open('eod.txt') as eod:
eod = eod.read().strip()
if eod == "1":
EOD_T = True
else:
EOD_T = False
if CSVFile and not EOD_T:
errors = open('ERROR(S).txt', 'a')
try:
execfile("SUBSCRIPTS/test.py", {})
except Exception:
errors.write(traceback.format_exc() + '\n')
errors.write("\n\n")
errors.close()
print """ %.3f seconds""" % (time() - st)
while True:
periodically(15, -10, +50, execute_subscripts)
有人知道我怎么能找出它为什么会崩溃,或者知道为什么,知道如何修复它吗?
谢谢
-海夫莱斯