'How to launch a subprocess in a new terminal?
Hello I am a beginner & sorry for my bad English. My question is how to launch a sub process in a new terminal?
For the moment I have launched a process Loop.py in a new terminal with a subprocess function:
Lo = subprocess.Popen(['gnome-terminal', '-x', 'python3', '/address/Loop.py'])
but it’s not quit the same thing, I don't have access to the script Loop.py from the main script.
Thank you.
Update:
the main script is Main.py:
import subprocess, signal, os, time
Li = subprocess.Popen(['gnome-terminal'])
Lo = subprocess.Popen(['python3', '/address/Loop.py'])
time.sleep(0.1)
Qd = subprocess.Popen(['python3', '/adress/Qdial.py'])
if Qd.wait() != None:
Lo.send_signal(signal.SIGINT)
Li.send_signal(signal.SIGKILL)
The Qdial.pyis describe here:
Qdial
The Loop.py is :
import time, signal
def handler(signum, frame):
print('Exit!')
exit()
signal.signal(signal.SIGINT, handler)
def loop():
with open('/addres/Data.py', 'r') as file:
lines = file.readlines()
A1 = lines[0]
A1 = float(A1[4:-1])
print('A1 = ', A1)
while True:
loop()
time.sleep(.1)
and the Data.py is a bunch of data, here I use just one:
A1 = 10
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
