Freezing pyevolve

28 views
Skip to first unread message

Marven

unread,
Jul 11, 2016, 8:32:09 AM7/11/16
to pyevolve
Dear Developers,

I started using pyevolve and I'm really enjoying it but I encountered a problem that I was not able fix yet, so I'm hoping any of you guys could help me.
I am trying to freeze my program to create a single executable (using py2exe). The .exe is created without any errors and (without multiprocessing) is running as expected, like it is when started from an IDE. But when I enabled the multiprocessing option of pyevolve, the program spawned a new version of my program for every core of my CPU. So I did some research and made a little change in the GPopulation.py:
I changed (line 42ff):

try:
from multiprocessing import cpu_count, Pool
CPU_COUNT = cpu_count()
MULTI_PROCESSING = True if CPU_COUNT > 1 else False
logging.debug("You have %d CPU cores, so the multiprocessing state is %s", CPU_COUNT, MULTI_PROCESSING)
except ImportError:
MULTI_PROCESSING = False
logging.debug("You don't have multiprocessing support for your Python version !")

to:

try:
from multiprocessing import cpu_count, Pool, freeze_support
freeze_support()
CPU_COUNT = cpu_count()
MULTI_PROCESSING = True if CPU_COUNT > 1 else False
logging.debug("You have %d CPU cores, so the multiprocessing state is %s", CPU_COUNT, MULTI_PROCESSING)
except ImportError:
MULTI_PROCESSING = False
logging.debug("You don't have multiprocessing support for your Python version !")

With these changes the program has stopped creating the new instances but now creates the following error for every worker in the process pool:

Process PoolWorker-XY:
Traceback (most recent call last):
  File "multiprocessing\process.pyc", line 258, in _bootstrap
  File "multiprocessing\process.pyc", line 114, in run
  File "multiprocessing\pool.pyc", line 102, in worker
  File "multiprocessing\queues.pyc", line 378, in get
AttributeError: 'module' object has no attribute 'multiprocessing_eval'

So it seems like the single workers can't see the 'multiprocessing_eval' anymore.
Does anyone have any idea how to fix that error?

Many thanks in advance!
Reply all
Reply to author
Forward
0 new messages