with PyQt I've made a GUI (gui.py) with a "start" and a "stop" button. Now I would like to start a another python script (streamData.py), which is in same directory as the GUI script, by pressing the start button. The streamData script is logging some sensor-Data to a file. If I press "stop" button the execution of the streamData script should be terminated.
What is the best way to achieve this? Should I import the streamData.py in my gui script? Or should I use some kind of processing module to start streamData as own process?
The streamData script has following functions inside:
def ctrl_c_handler(signal, frame, node)
raise Exception("")
node = someNode()
def main():
signal.signal(signalSIGINT, ctrl_c_handler)
while 1:
node.stream()
if __name__ == "__main__":
main()
if printInformation: print("disconnected")
node.disconnect()
time.sleep(1)
exit(0)
So is there a way to get the script execution in node.stream let jump to
node.disconnect()
time.sleep(1)
exit(0)
?