From d018ee95cf9b0e850e35b54e622af3ca18b24f3e Mon Sep 17 00:00:00 2001 From: Joe Banks Date: Thu, 9 Oct 2025 21:57:48 +0100 Subject: Update nsjail tests to try avoid multiprocessing exception --- tests/test_nsjail.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index 01be592..85bee68 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -108,17 +108,17 @@ class NsJailTests(unittest.TestCase): object = "A" * 40_000_000 time.sleep(0.5) + if __name__ == "__main__": + proc_1 = Process(target=f) + proc_2 = Process(target=f) - proc_1 = Process(target=f) - proc_2 = Process(target=f) + proc_1.start() + proc_2.start() - proc_1.start() - proc_2.start() + proc_1.join() + proc_2.join() - proc_1.join() - proc_2.join() - - print(proc_1.exitcode, proc_2.exitcode) + print(proc_1.exitcode, proc_2.exitcode) """ ) @@ -137,8 +137,9 @@ class NsJailTests(unittest.TestCase): def f(x): return x*x - with Pool(2) as p: - print(p.map(f, [1, 2, 3])) + if __name__ == "__main__": + with Pool(2) as p: + print(p.map(f, [1, 2, 3])) """ ) -- cgit v1.2.3