简体   繁体   English

Python多处理不调用函数

[英]Python multiprocessing not calling function

I'm trying to get this code to work, and it looks like update isn't getting called. 我正在尝试使此代码正常工作,并且好像没有调用update。 Nothing is printed to the console with this code, why? 此代码没有打印到控制台,为什么?

from multiprocessing import Process

def update():
    print("hi")

if __name__ == '__main__':
    p = Process(target=update, args=())
    p.start()
    p.join()

从命令行运行程序,python idle无法正确处理此操作,如此处所述

Sorry for the stupid answer, but maybe you do not have time to see the output in stdout? 很抱歉这个愚蠢的答案,但是也许您没有时间在stdout中看到输出? Try running the script from the command line, like this: c:\\<script location>\\script.py 尝试从命令行运行脚本,如下所示: c:\\<script location>\\script.py

UPD: riscnotcisc said true. UPD:riscnotcisc说的是真的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM