我有两个函数可以做一些事情。我需要它们同时运行,直到出现异常情况,所以我使用了多处理,但是每当我执行我的代码时,它都会从代码的开头无限运行,其中有几行代码,然后是我的两个函数。我的代码看起来像这样:
'''
few line of code
'''
def func_1():
# Do Somthing
def func_2():
# Do Somthing
while True:
try:
if __name__ == '__main__':
sensor_process = Process(target=sensor)
sensor_process.start()
balance_process = Process(target=balance_fun)
balance_process.start()
except(KeyboardInterrupt, SystemExit):
break
我的代码从一开始就无限执行,或者问题出在其他地方,我的多处理有什么问题吗?
一只斗牛犬
拉丁的传说
潇潇雨雨
相关分类