[issue17038] multiprocessing only use one core when C module are imported

Charles-François Natali report at bugs.python.org
Sat Jan 26 12:28:23 CET 2013


Charles-François Natali added the comment:

Hello,

> So I'm sorry if it's not a bug...

Don't be afraid, we don't byte :-)

Concerning your problem, my guess would be that one of the modules you import sets the process CPU affinity (maybe as a workaround to mitigate the GIL impact in multi-threaded code, or whatever) upon import.

And a quick google search returns this:
https://github.com/ipython/ipython/issues/840

To confirm this, you can just do:
strace -e sched_setaffinity python -c "import numpy"


You can also add
"""
    for line in open('/proc/self/status'):
        if 'Cpu' in line:
            print(line)
"""

Right before and after importing the module, and you'll see that the CPU affinity has changed.

----------
nosy: +neologix

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17038>
_______________________________________


More information about the Python-bugs-list mailing list