0

I have some code where I am generating indexes as follows:

import numpy as np
from multiprocessing import Pool

def compute(idx, ix, kx, im, f):
   im[idx[0], idx[1]] = func1([[ix[0], ix[1]]])
   f[idx[0], idx[1]] = func2([[kx[0], kx[1]]])[0]


N = 256
max_k = 32
g = np.zeros(N, N)
k = np.zeros(N, N)

# These will be used to generate some indexes and sampling points
ix = np.linspace(-1, 1, N)
iy = np.linspace(-1, 1, N)

kx = np.linspace(-max_k, max_k, N)
ky = np.linspace(-max_k, max_k, N)

p = Pool()

for idy, yi, yf in zip(count(), iy, ky):
    for idx, xi, xf in zip(count(), ix, kx):
        p.apply_async(compute,args=([idx, idy], [xi, yi], [xf, yf],
                      g, k))

p.close()
p.join()

Here func1 and func2 are some functions that get called. Now when I run this I get tons of errors and basically the gist is as follows:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
    exitcode = _main(fd)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
  File "<string>", line 1, in <module>
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    run_name="__mp_main__")
Traceback (most recent call last):
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
Traceback (most recent call last):
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "<string>", line 1, in <module>
    exitcode = _main(fd)
    exitcode = _main(fd)
    exitcode = _main(fd)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
Traceback (most recent call last):
    exitcode = _main(fd)
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
Traceback (most recent call last):
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
  File "<string>", line 1, in <module>
    exitcode = _main(fd)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
    pkg_name=pkg_name, script_name=fname)
    exitcode = _main(fd)
    prepare(preparation_data)
    prepare(preparation_data)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    exitcode = _main(fd)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "<string>", line 1, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    exitcode = _main(fd)
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    mod_name, mod_spec, pkg_name, script_name)
    prepare(preparation_data)
    _fixup_main_from_path(data['init_main_from_path'])
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 106, in spawn_main
    exitcode = _main(fd)
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    exitcode = _main(fd)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    prepare(preparation_data)
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    exec(code, run_globals)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    exec(code, run_globals)
    _fixup_main_from_path(data['init_main_from_path'])
    run_name="__mp_main__")
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 115, in _main
    prepare(preparation_data)
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    run_name="__mp_main__")
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    prepare(preparation_data)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    _fixup_main_from_path(data['init_main_from_path'])
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
    p = Pool()
    run_name="__mp_main__")
    pkg_name=pkg_name, script_name=fname)
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 226, in prepare
    _fixup_main_from_path(data['init_main_from_path'])
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    _fixup_main_from_path(data['init_main_from_path'])
    pkg_name=pkg_name, script_name=fname)
    run_name="__mp_main__")
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
    context=self.get_context())
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 278, in _fixup_main_from_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    run_name="__mp_main__")
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    context=self.get_context())
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    run_name="__mp_main__")
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    exec(code, run_globals)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 240, in run_path
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    self._repopulate_pool()
    pkg_name=pkg_name, script_name=fname)
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
    mod_name, mod_spec, pkg_name, script_name)
    self._repopulate_pool()
    exec(code, run_globals)
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    pkg_name=pkg_name, script_name=fname)
    exec(code, run_globals)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    p = Pool()
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 96, in _run_module_code
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    w.start()
    mod_name, mod_spec, pkg_name, script_name)
    exec(code, run_globals)
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    p = Pool()
    exec(code, run_globals)
    w.start()
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    mod_name, mod_spec, pkg_name, script_name)
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    context=self.get_context())
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\runpy.py", line 85, in _run_code
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    exec(code, run_globals)
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    self._popen = self._Popen(self)
    context=self.get_context())
    p = Pool()
    self._popen = self._Popen(self)
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    exec(code, run_globals)
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    self._repopulate_pool()
    self._repopulate_pool()
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
  File "C:\Users\Pankaj\development\gsp\mri-simulator\synth\Recon2DPhantomExample.py", line 40, in <module>
    self._repopulate_pool()
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    return Popen(process_obj)
    self._repopulate_pool()
    context=self.get_context())
    return Popen(process_obj)
    self._repopulate_pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
    p = Pool()
    p = Pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    self._repopulate_pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
    w.start()
    w.start()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 118, in Pool
    w.start()
    self._repopulate_pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    w.start()
    w.start()
    self._repopulate_pool()
    w.start()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
    context=self.get_context())
    context=self.get_context())
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 144, in get_preparation_data
    self._popen = self._Popen(self)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 168, in __init__
    self._popen = self._Popen(self)
    w.start()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 144, in get_preparation_data
    self._popen = self._Popen(self)
    self._popen = self._Popen(self)
    w.start()
    self._popen = self._Popen(self)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
    _check_not_importing_main()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
    self._repopulate_pool()
    self._repopulate_pool()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
    _check_not_importing_main()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 137, in _check_not_importing_main
    return Popen(process_obj)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\pool.py", line 233, in _repopulate_pool
    return Popen(process_obj)
    self._popen = self._Popen(self)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 137, in _check_not_importing_main
    return Popen(process_obj)
    return Popen(process_obj)
    self._popen = self._Popen(self)
    return Popen(process_obj)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    is not going to be frozen to produce an executable.''')
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    w.start()
    w.start()
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
    is not going to be frozen to produce an executable.''')
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\context.py", line 313, in _Popen
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\process.py", line 105, in start
    prep_data = spawn.get_preparation_data(process_obj._name)
    return Popen(process_obj)
RuntimeError:
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.    prep_data = spawn.get_preparation_data(process_obj._name)
    prep_data = spawn.get_preparation_data(process_obj._name)
    return Popen(process_obj)
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "C:\Users\Pankaj\Anaconda3\envs\py325\lib\multiprocessing\spawn.py", line 144, in get_preparation_data

I am not sure what I am doing wrong but any advice would be helpful!

Luca
  • 10,458
  • 24
  • 107
  • 234
  • Your traceback seems to be incomplete, could you add the missing parts? – Ilja Everilä Apr 06 '16 at 12:20
  • Also, you seem to pass `g` and `k` to `compute` and then inline assign some values to them (`im` and `f` in compute). This will not update the global values `g` and `k` in the process calling `p.apply_async`. – Ilja Everilä Apr 06 '16 at 12:23
  • @Ilja The full trace is big as it probably prints for every element but I added some more. Could you elaborate on the second comment? – Luca Apr 06 '16 at 12:25
  • http://stackoverflow.com/questions/419163/what-does-if-name-main-do, you should not run your main functionality at module scope like that. – Ilja Everilä Apr 06 '16 at 12:25
  • I am running it as a simple script actually. I do not have any explicit __main__ function. – Luca Apr 06 '16 at 12:25
  • 1
    Actually, http://stackoverflow.com/questions/34853707/runtimeerror-of-python-occers-on-windows-to-multiprocessing is exactly your problem – Ilja Everilä Apr 06 '16 at 12:27
  • Thanks for that. I will give it a try.... – Luca Apr 06 '16 at 12:29
  • 1
    That answer skips explaining why that happens. The new process has to import the function to run from the module, so it'll try and do that, which triggers your "main" code again, which will try and do all the Pool stuff again. See "Safe importing of main module" in [multiprocessing programming](https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming) – Ilja Everilä Apr 06 '16 at 12:31
  • Thanks for that. It removed that error! – Luca Apr 06 '16 at 12:41

0 Answers0