问题描述
我有一个python脚本,当我通过命令行或通过编辑器运行该脚本时,它不会出现任何问题。但是,一旦将其设置为通过Task Scheduler自动运行,我的日志中就会出现MemoryErrors。
这是错误消息:
MemoryError: Unable to allocate 2.03 MiB for an array with shape (10252,52) and data type object
任何可能出问题的建议都会受到赞赏。
谢谢。
解决方法
我还没有直接解决我的问题,但是我仍然有一个可能对某些人来说很方便的解决方案。
最后,我放弃了任务计划,而是创建了一个新的Python脚本,该脚本在特定时间运行我的所有Python脚本。该库称为Schedule。
import schedule
from MODULE_1 import FUNCTION_1
from MODULE_2 import FUNCTION_2
schedule.every().monday.at(13:20).do(FUNCTION_1)
schedule.every().monday.at(20:10).do(FUNCTION_2)
while True:
try:
schedule.run_pending()
except Exception as f:
e = datetime.datetime.now()
print(e.strftime("%Y-%m-%d %H:%M:%S"))
print("ERROR TYPE:")
print(f)
time.sleep(1)