【发布时间】:2018-09-27 15:55:59
【问题描述】:
您好,我正在使用多处理库从 main() 运行两个不同的函数:
Coap = multiprocessing.Process(target=runCoapSync(iotComponent))
huis=multiprocessing.Process(target=runHuis(iotComponent))
huis.start()
Coap.start()
问题是函数runHuis() 没有被触发,但是如果我注释行以运行另一个函数,函数runHuis() 会按预期工作。我在代码的其他地方使用了相同的结构,但效果很好。
这是两个函数的代码:
def runHuis(iotDevice):
print("----------------1---------------")
LCD=iotDevice.connectedHUIs[0]
while True:
LCD.alertHuman(iotDevice.connectedSensors[0].data.value)
def runCoapSync(iotDevice):
print("----------------2---------------")
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(runCoap(iotDevice))
【问题讨论】:
-
这是什么版本的 Python?您在哪个操作系统上运行?
-
我正在使用树莓派上的 Python3,所以操作系统是树莓派