[英]How can I run multiple python files at the same time in Mac OSX
I have been searching and every solution I find is for Windows specific.我一直在搜索,我找到的每个解决方案都是针对 Windows 特定的。 I am looking for a way to run multiple python programs at one time.
我正在寻找一种同时运行多个 python 程序的方法。 I have tried
我努力了
import test1导入测试1
import test2导入测试2
and i only get one of them at a time.我一次只能得到其中一个。 I am needing both to be ran at the same time.
我需要同时运行两者。
Any help is appreciated!任何帮助表示赞赏!
To run Python code in parallel, please refer to the module multiprocessing .要并行运行 Python 代码,请参阅模块multiprocessing 。
from multiprocessing import Process
def first_import():
import test1
def second_import():
import test2
if __name__ == '__main__':
first_process = Process(target=first_import)
second_process = Process(target=second_import)
first_process.start()
second_process.start()
first_process.join()
second_process.join()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.