I am trying to make a temperature monitoring module that continuously saves the current temperature in a file, and then uses matplotlib to draw a graph as soon as it is used for decoration. This functionality works for me, so I can use it as:
with TemperatureMonitoring():
When __enter__ called, the process begins, which is just an endless loop that sleeps and writes to the file, and when __exit__ receives the call, the process ends and the file is displayed on the screen.
Now I want to make improvements, so I want the child process to control the parent; if the temperature is too high for too long, it will stop and wait for the computer to cool. This is my first time with the multiprocessing module, but it seems that if I pause the main process, the child also pauses. Therefore, if I reach a critical state, he will not be able to disconnect himself. Thus, the parent should be able to interrupt it when the code has completed execution, and the child should be able to pause / resume the parent process, if necessary. Is there an obvious way to do this?
source share