Skip to content

3.15 profiling, can't use ProcessPoolExecutor.map() in a simple script#140729

@dimaqq

Description

@dimaqq

Bug report

Bug description:

# test/test_unit.pyimportconcurrent.futures ... defexercise(units=11, rounds=2): withconcurrent.futures.ProcessPoolExecutor() asexecutor: ... results=list( executor.map( step, [f"app/{i}"foriinrange(units)], [config] *units, [local_app_data] *units, [peers_data] *units, ) ) defstep( 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__": importsysexercise(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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions