Wait for thread to start

This commit is contained in:
Foo 2017-12-02 17:32:42 +03:00
parent 0c594b0b34
commit 1b0df9c2bd
1 changed files with 3 additions and 0 deletions

View File

@ -61,6 +61,7 @@ class ExpectProcess(threading.Thread):
self.buffer = [] self.buffer = []
self.child_lock = threading.Lock() self.child_lock = threading.Lock()
self.shutdown_event = threading.Event() self.shutdown_event = threading.Event()
self.started_event = threading.Event()
def run(self): def run(self):
with self.child_lock: with self.child_lock:
@ -70,6 +71,7 @@ class ExpectProcess(threading.Thread):
child.setwinsize(self.dim.rows, self.dim.cols) child.setwinsize(self.dim.rows, self.dim.cols)
sleep(0.5) sleep(0.5)
self.child = child self.child = child
self.started_event.set()
status = None status = None
while status is None and not self.shutdown_event.is_set(): while status is None and not self.shutdown_event.is_set():
try: try:
@ -270,6 +272,7 @@ def do_terminal_tests(tests, cmd, dim, args, env, suite, cwd=None, fin_cb=None,
env=env, env=env,
) )
p.start() p.start()
p.started_event.wait()
ret = True ret = True