从另一个进程终止进程

时间:2018-01-17 08:27:51

标签: python process subprocess

我正在尝试制作一个LCD显示屏,以便在不同的行中同时显示当前温度和湿度。我有一个示例代码如下。问题是,当温度高于50℃时,我希望湿度读数也能停止。我有2个线程同时运行,从两个传感器读取。

#all important imports are here

 def main():

    # Very simplified code, not actual.

    tempP = Process(target=temperature)
    humidP = Process(target=humidity)

    tempP.start()
    humidP.start()

 def temperature():

    while True:
       #ADC printing to LCD code is here
        temperatureReading = ADC.channel(0)
       if temperatureReading > 50:
          humidP.terminate() # Does not work, I still see the humidity on

重叠字符的屏幕

0 个答案:

没有答案