jmborr / nscsim

calculation of neutron scattering functions for powder, amorphous, confined, and liquid materials
MIT License
2 stars 1 forks source link

nscsim: why can't I can open another pathos pool in the notebook? #31

Open jmborr opened 5 years ago

jmborr commented 5 years ago

after calculating the coherent scattering with, say, 4 cores. I try the calculation of another coherent scattering with 8 cores. too. Then I get the error that the pool is not open.

sf = coh.intermediate_spherical(tr, q_mod, b_c, n_cores=4)
....
sf = coh.intermediate_spherical(tr_other, q_mod_other, b_c, n_cores=4)

~/.virtualenvs/nscsim3.6/lib/python3.6/site-packages/multiprocess/pool.py in _map_async(self, func, iterable, mapper, chunksize, callback, error_callback)
    372         '''
    373         if self._state != RUN:
--> 374             raise ValueError("Pool not running")
    375         if not hasattr(iterable, '__len__'):
    376             iterable = list(iterable)

ValueError: Pool not running
ConnorPigg commented 5 years ago

Try putting pool.restart(force=True) before using the pool or after defining the pool variable. This should allow you to close the pool but reset the recycled pathos pool object between uses.

jmborr commented 5 years ago

yes, I noticed you had that line in incoheren2.py :smile: