Skip to content

Commit d018ee9

Browse files
committed
Update nsjail tests to try avoid multiprocessing exception
1 parent f174f41 commit d018ee9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tests/test_nsjail.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,17 @@ def f():
108108
object = "A" * 40_000_000
109109
time.sleep(0.5)
110110
111+
if __name__ == "__main__":
112+
proc_1 = Process(target=f)
113+
proc_2 = Process(target=f)
111114
112-
proc_1 = Process(target=f)
113-
proc_2 = Process(target=f)
115+
proc_1.start()
116+
proc_2.start()
114117
115-
proc_1.start()
116-
proc_2.start()
118+
proc_1.join()
119+
proc_2.join()
117120
118-
proc_1.join()
119-
proc_2.join()
120-
121-
print(proc_1.exitcode, proc_2.exitcode)
121+
print(proc_1.exitcode, proc_2.exitcode)
122122
"""
123123
)
124124

@@ -137,8 +137,9 @@ def test_multiprocessing_pool(self):
137137
def f(x):
138138
return x*x
139139
140-
with Pool(2) as p:
141-
print(p.map(f, [1, 2, 3]))
140+
if __name__ == "__main__":
141+
with Pool(2) as p:
142+
print(p.map(f, [1, 2, 3]))
142143
"""
143144
)
144145

0 commit comments

Comments
 (0)