您好,我正在使用多处理库从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))
multiprocessing.Process
要求target是可调用的可选参数:因为您正在调用它,所以剩余的程序将等待
runCoapSync
完成相关问题 更多 >
编程相关推荐