You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
3.15 profiling, can't use ProcessPoolExecutor.map() in a simple script #140729
This is interesting
its very similar like viztracer issue which is gaogaotiantian/viztracer#423
in ProcessPoolExecutor() the __main__ may because __mp_main__
The execution of ttt.py script fails when run via the cProfile module as below:
python -m cProfile /Users/yves/Desktop/Bugs/gh-140729.py
Process SpawnProcess-1:
Traceback (most recent call last):
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/process.py", line 320, in _bootstrap
self.run()
~~~~~~~~^^
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/concurrent/futures/process.py", line 242, in _process_worker
call_item = call_queue.get(block=True)
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/queues.py", line 115, in get
return _ForkingPickler.loads(res)
~~~~~~~~~~~~~~~~~~~~~^^^^^
AttributeError: module '__main__' has no attribute 'worker'
and with the profile module too.
Based on my initial tests, the proposed fix is not valid for these two modules. Should we open a new issue ?
The execution of ttt.py script fails when run via the cProfile module as below:
python -m cProfile /Users/yves/Desktop/Bugs/gh-140729.py
Process SpawnProcess-1:
Traceback (most recent call last):
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/process.py", line 320, in _bootstrap
self.run()
~~~~~~~~^^
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/concurrent/futures/process.py", line 242, in _process_worker
call_item = call_queue.get(block=True)
File "/Users/yves/Documents/_Jobs/_Clients/cpython2/cpython/Lib/multiprocessing/queues.py", line 115, in get
return _ForkingPickler.loads(res)
~~~~~~~~~~~~~~~~~~~~~^^^^^
AttributeError: module '__main__' has no attribute 'worker'
and with the profile module too.
Based on my initial tests, the proposed fix is not valid for these two modules. Should we open a new issue ?
@picnixz, @StanFromIreland I am wondering if a topic-profiling (if exists) or a topic-multiprocessing label should not be better than topic-subinterpreters.
@pablogsal Do you agree to add the fix about the cProfilemodule in this current linked PR or it is better to create a new PR ?
Certainly a new PR
update: The fix about the cProfiler module needs the modifications of the profiling/sampling/_sync_coordinator.pyfile.
That would be a bit more aggressive that what I would like since that addition can have some unintended side effects but if you want to give it a go to see how it looks let's try it
@pablogsal Do you agree to add the fix about the cProfilemodule in this current linked PR or it is better to create a new PR ?
Certainly a new PR
Ok, I have got a new PR dedicated to the cProfile module
update: The fix about the cProfiler module needs the modifications of the profiling/sampling/_sync_coordinator.pyfile.
That would be a bit more aggressive that what I would like since that addition can have some unintended side effects but if you want to give it a go to see how it looks let's try it
Thank you for your agreement. But after working about the PR, I realize I don't need this correction. We can be cool, there won't be any side effects. Sorry for this comment
Activity
picnixz commentedon Oct 28, 2025
cc @pablogsal
yihong0618 commentedon Oct 29, 2025
This is interesting
its very similar like viztracer issue which is gaogaotiantian/viztracer#423
in ProcessPoolExecutor() the
__main__may because__mp_main__a simple reproducer
cat ttt.py
the patch can be like what viztracer did
after the patch
cc @dimaqq
mehetabalom181-lab commentedon Oct 29, 2025
YvesDup commentedon Oct 30, 2025
The execution of
ttt.pyscript fails when run via thecProfilemodule as below:and with the
profilemodule too.Based on my initial tests, the proposed fix is not valid for these two modules. Should we open a new issue ?
yihong0618 commentedon Oct 30, 2025
using the same method can fix this?
YvesDup commentedon Oct 30, 2025
I don`t know yet
YvesDup commentedon Oct 30, 2025
@picnixz, @StanFromIreland I am wondering if a topic-profiling (if exists) or a topic-multiprocessing label should not be better than topic-subinterpreters.
StanFromIreland commentedon Oct 30, 2025
I added topic-multiprocessing, FYI all labels are listed here. topic-profiling
does not exist.10 remaining items
pablogsal commentedon Nov 17, 2025
Thanks everyone for the help! ❤️
pablogsal commentedon Nov 17, 2025
Certainly a new PR
That would be a bit more aggressive that what I would like since that addition can have some unintended side effects but if you want to give it a go to see how it looks let's try it
pablogsal commentedon Nov 17, 2025
Reopening until we figure out Profile
pythongh-140729: Fix subprocess handling in test_process_pool_executo…
gh-140729: Fix subprocess handling in test_process_pool_executor_pick…
YvesDup commentedon Nov 20, 2025
Ok, I have got a new PR dedicated to the
cProfilemoduleThank you for your agreement. But after working about the PR, I realize I don't need this correction. We can be cool, there won't be any side effects. Sorry for this comment
pythongh-140729: Add __mp_main__ as a duplicate for __main__ for pick…
pythongh-140729: Fix subprocess handling in test_process_pool_executo…
gh-140729: Fix the cProfile module when the executed script contains …
[3.15] gh-140729: Fix the cProfile module when the executed script co…
[3.14] gh-140729: Fix the cProfile module when the executed script co…