forked from StephenGss/PAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testThread.py
26 lines (20 loc) · 1015 Bytes
/
testThread.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import threading, socket, subprocess, sys
class TestThread(threading.Thread):
def __init__(self, command, args=(), kwargs=None):
threading.Thread.__init__(self, args=(), kwargs=None)
self.command = command
def run(self):
print("Initializing Agent Thread: " + self.command)
# agent = subprocess.Popen(self.command, shell=True, stdout=subprocess.PIPE)
log = open('agent_log.txt', 'w')
agent = subprocess.Popen(["python", "hg_agent.py"], shell=False, stdout=log, stderr=log)
while True:
# grab the console output of PAL
# next_line = agent.stdout.readline()
# first check if we crashed or something... hopefully this doesn't happen
if agent.poll() is not None:
break
# if len(str(next_line)) > 3:
# # print for debugging
# sys.stdout.write("[AGENT] " + str(next_line) + '\n')
# sys.stdout.flush()