Skip to content

Commit 8b93ec3

Browse files
committed
fix: apply suggestions
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
1 parent 9c6c76b commit 8b93ec3

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

Lib/test/test_profiling/test_sampling_profiler.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3038,16 +3038,23 @@ def worker(x):
30383038
temp_dir, 'test_process_pool_executor_pickle', test_script
30393039
)
30403040
with SuppressCrashReport():
3041-
with script_helper.spawn_python(script, stderr=subprocess.PIPE) as proc:
3042-
proc.wait()
3041+
with script_helper.spawn_python(
3042+
"-m", "profiling.sampling.sample",
3043+
"-d", "1",
3044+
"-i", "100000",
3045+
script,
3046+
stderr=subprocess.PIPE,
3047+
text=True
3048+
) as proc:
3049+
proc.wait(timeout=10)
30433050
stdout = proc.stdout.read()
30443051
stderr = proc.stderr.read()
30453052

3046-
if b"PermissionError" in stderr:
3053+
if "PermissionError" in stderr:
30473054
self.skipTest("Insufficient permissions for remote profiling")
30483055

3049-
self.assertIn(b"Results: [2, 4, 6]", stdout)
3050-
self.assertNotIn(b"Can't pickle", stderr)
3056+
self.assertIn("Results: [2, 4, 6]", stdout)
3057+
self.assertNotIn("Can't pickle", stderr)
30513058

30523059

30533060
if __name__ == "__main__":
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Fix: Add __mp_main__ as a duplicate for __main__ for pickle to work in
2-
sampling
1+
Fix pickling error in the sampling profiler when using ``concurrent.futures.ProcessPoolExecutor``
2+
script can not be properly pickled and executed in worker processes.

0 commit comments

Comments
 (0)