首页 > 解决方案 > windows下调度模块崩溃

问题描述

我在 Windows 上运行脚本时遇到了这个错误。但是,该脚本在 linux 环境下运行良好,我无法理解错误的性质。这是代码和控制台错误。

import time
import schedule
import subprocess
import os
import multiprocessing


dir = os.path.dirname(os.path.abspath(__file__))
path_phoenix=os.path.join(dir, 'sub','phoenix', 'automated_Phoenix.py')
path_singlephoenix=os.path.join(dir, 'sub','single_phoenix', 'automated_SinglePhoenix.py')
path_brc=os.path.join(dir, 'sub','brc', 'automated_BRC.py')
path_singlebrc=os.path.join(dir, 'sub','single_brc', 'automated_SingleBRC.py')
path_outperformance=os.path.join(dir, 'sub','outperformance', 'automated_Outperformance.py')
path_cpc=os.path.join(dir, 'sub','cpc', 'automated_CPC.py')


def autorun():
    print("I'm working...")
    def phoenix(file):
        subprocess.run(['python', path_phoenix])
    def singlephoenix(file):
        subprocess.run(['python', path_singlephoenix])
    def brc(file):
        subprocess.run(['python', path_brc])
    def singlebrc(file):
        subprocess.run(['python', path_singlebrc])
    def outperformance(file):
        subprocess.run(['python', path_outperformance])
    def cpc(file):
        subprocess.run(['python', path_cpc]) 


    if __name__ == '__main__':
        files = [path_phoenix, path_singlephoenix, path_brc, path_singlebrc, path_outperformance, path_cpc]
        for i in files:
            p = multiprocessing.Process(target=phoenix, args=(i,))
            q = multiprocessing.Process(target=brc, args=(i,))
            s = multiprocessing.Process(target=outperformance, args=(i,))
            t = multiprocessing.Process(target=cpc, args=(i,))
            u = multiprocessing.Process(target=singlephoenix, args=(i,))
            v = multiprocessing.Process(target=singlebrc, args=(i,))
            p.start()
            q.start()
            s.start()
            t.start()
            u.start()
            v.start()
            p.join()
            q.join()
            s.join()
            t.join()
            u.join()
            v.join()

schedule.every().day.at("01:09").do(autorun)

while True:
    schedule.run_pending()
    time.sleep(1)

在此处输入图像描述

你知道我为什么会出现这个错误吗?请帮忙,谢谢

视窗 10 Python 3.8.5

标签: pythonpython-3.xwindowsschedulemultiprocess

解决方案


推荐阅读