Bug report
Bug description:
# test/test_unit.py import concurrent.futures ... def exercise(units=11, rounds=2): with concurrent.futures.ProcessPoolExecutor() as executor: ... results = list( executor.map( step, [f"app/{i}" for i in range(units)], [config] * units, [local_app_data] * units, [peers_data] * units, ) ) def step( unit: str, config: Mapping[str, str | int | float | bool], local_app_data: Mapping[str, JSON], all_units_data: Mapping[ops.testing.UnitID, Mapping[str, JSON]], ) -> tuple[dict[str, JSON] | None, dict[str, JSON], str | None, str]: ... if __name__ == "__main__": import sys exercise(int(sys.argv[1]), int(sys.argv[2]))
(jgol-peer) 🦐/c/j/peer (main)> sudo -E env PYTHONPATH=src python -m profiling.sampling test/test_unit.py 100 100 Profiler coordinator error: Error executing script '/code/jgol/peer/test/test_unit.py': Can't pickle <function step at 0x102b7aae0>: it's not found as __main__.step
CPython versions tested on:
3.15
Operating systems tested on:
macOS
Linked PRs
- gh-140729: Add __mp_main__ as a duplicate for __main__ for pickle to work #140735
- gh-140729: Fix subprocess handling in test_process_pool_executor_pickle #141688
- gh-140729: profiling or tracing multiprocessing can cause error #141874
- gh-140729: Fix the cProfile module when the executed script contains calls to multiprocessing.Process #144700
- gh-140729: Fix the cProfile module when the executed script contains calls to multiprocessing.Process #144715
- [3.15] gh-140729: Fix the cProfile module when the executed script contains calls to multiprocessing.Process (GH-144715) #153243
- [3.14] gh-140729: Fix the cProfile module when the executed script contains calls to multiprocessing.Process (GH-144715) #153265