@@ -191,8 +191,7 @@ class Foo:
191191 f .close ()
192192 assert_python_ok ('-m' , "cProfile" , f .name )
193193
194- def test_process_run_pickle (self ):
195- # gh-140729: test use Process in cProfile.
194+ def _test_process_run_pickle (self , start_method ):
196195 val = 10
197196 with tempfile .NamedTemporaryFile ("w+" , delete_on_close = False ) as f :
198197 f .write (textwrap .dedent (
@@ -204,7 +203,7 @@ def worker(x):
204203 exit(x ** 2)
205204
206205 if __name__ == "__main__":
207- multiprocessing.set_start_method("spawn" )
206+ multiprocessing.set_start_method(' { start_method } ' )
208207 p = multiprocessing.Process(target=worker, args=({ val } ,))
209208 p.start()
210209 p.join()
@@ -216,6 +215,14 @@ def worker(x):
216215 self .assertIn (bytes (f"exitcode = { val ** 2 } " , encoding = 'utf8' ), out )
217216 self .assertNotIn (b"Can't pickle" , err )
218217
218+ def test_process_spawn_pickle (self ):
219+ # gh-140729: test use Process in cProfile.
220+ self ._test_process_run_pickle ('spawn' )
221+
222+ def test_process_forkserver_pickle (self ):
223+ # gh-140729: test use Process in cProfile.
224+ self ._test_process_run_pickle ('forkserver' )
225+
219226
220227def main ():
221228 if '-r' not in sys .argv :
0 commit comments