pyinstaller构建后的多处理问题

时间:2019-03-04 15:14:27

标签: python windows multiprocessing pyinstaller

我正在尝试在python中进行多重处理。当我在Pycharm中运行代码时,一切正常。然后我用pyinstaller创建了“ exe”文件。当我启动“ exe”文件程序时,将启动很多进程(在任务管理器中)。我不明白为什么...

这是我的多处理功能:

def multiprocess_with_shutdown(target_function_name=None, process_name=None, hour=0, minute=0):
    from multiprocessing import Process
    from datetime import datetime, timedelta

    p = Process(target=target_function_name, name=str(process_name))

    stop_time = datetime(year=datetime.now().year,
                         month=datetime.now().month,
                         day=datetime.now().day,
                         hour=int(hour),
                         minute=int(minute))

    p.start()

    while True:
        if datetime.now() - stop_time > timedelta(minutes=0):
            p.terminate()
            p.join()
            logging.debug(f'{process_name} terminated at {datetime.now()}')
            break

此功能我设置为目标:

def start_main_process():
    running_seconds = 0
    while True:

        running_seconds = 30 + running_seconds

        if datetime.datetime.now().strftime("%H:%M") in main_notification_time_list:
            notification_main_process_function(True)
            sleep(60)
            running_seconds = 60 + running_seconds

        if running_seconds % build_info_storing_seconds == 0:
            notification_main_process_function()

        sleep(30)

0 个答案:

没有答案