diff --git a/src/lib/jrpc.py b/src/lib/jrpc.py index 0b0cc9c..0820184 100644 --- a/src/lib/jrpc.py +++ b/src/lib/jrpc.py @@ -228,7 +228,7 @@ class JsonRpcConnection: self.recv_thread.join() def is_alive(self): - self.recv_thread.is_alive() + return self.recv_thread.is_alive() def wait_ready(self, timeout=None): return self._event_ready.wait(timeout) diff --git a/src/testium/interpreter/test_items/test_item_dialog_base.py b/src/testium/interpreter/test_items/test_item_dialog_base.py index ce11cf2..f6056b4 100644 --- a/src/testium/interpreter/test_items/test_item_dialog_base.py +++ b/src/testium/interpreter/test_items/test_item_dialog_base.py @@ -1,7 +1,9 @@ -from multiprocessing import Process, Pipe +import multiprocessing from interpreter.test_items.test_item import TestItem +_spawn_ctx = multiprocessing.get_context('spawn') + class TestItemDialogBase(TestItem): """Base class for test items that launch a Qt dialog in a subprocess.""" @@ -19,7 +21,7 @@ class TestItemDialogBase(TestItem): Returns the subprocess exit code. """ - p = Process(target=target, args=(args,)) + p = _spawn_ctx.Process(target=target, args=(args,)) p.start() while p.is_alive() and not self._is_stopped: p.join(timeout=0.5) @@ -31,9 +33,10 @@ class TestItemDialogBase(TestItem): Returns the received value, or None if stopped or if the subprocess crashed. """ - parent_conn, child_conn = Pipe() - p = Process(target=target, args=(args, child_conn)) + parent_conn, child_conn = _spawn_ctx.Pipe() + p = _spawn_ctx.Process(target=target, args=(args, child_conn)) p.start() + child_conn.close() result = None while p.is_alive() and not self._is_stopped: if parent_conn.poll(0.5): diff --git a/src/testium/main_win/test_file_manager.py b/src/testium/main_win/test_file_manager.py index 95158a2..fa35b14 100644 --- a/src/testium/main_win/test_file_manager.py +++ b/src/testium/main_win/test_file_manager.py @@ -30,7 +30,13 @@ class TestFileManager: ): w.test_service.stop() w.test_service.close() - w.test_proc.join() + w.test_proc.join(timeout=5) + if w.test_proc.is_alive(): + w.test_proc.terminate() + w.test_proc.join(timeout=2) + if w.test_proc.is_alive(): + w.test_proc.kill() + w.test_proc.join() del w.test_proc w.test_proc = None del w.test_service