Closed bailer-jones closed 6 months ago
Hey @bailer-jones, thanks for the bug report! This is a quirk of Python multiprocessing that has to do with the Python global interpreter lock (GIL). It has to do with how Python initiates multiple parallel processes-- it creates a copy of the code, and each subprocess then runs using its own copy. Protecting the entry point (i.e. wrapping in if __name__ == '__main__'
like you did) is necessary for making sure Python knows not to go on infinitely creating more subprocesses. There are multiple ways of actually creating the subprocesses (see here), but not all of them work across operating systems. You can try out the different methods-- they should all (I think) work in orbitize!, depending on your OS.
tl;dr-- this is orbitize! working as expected, and the error message thrown seems to have guided you toward the correct solution, so I don't think we'll change anything here.
Please reopen if my answer isn't clear and/or if you run into other related issues.
I am using the MCMC sampler for fitting the orbit of a single planet. If I run my code directly in the terminal, I get the following error:
The code then seems to run forever. I do not get this error if I run the same code in a Jupyter notebook (i.e. interactively).
I am running orbitize 2.2.2 in python 3.9.18 on MacOs Sonoma 14.3 An outline of my set up is as follows:
I think the problem originate MCMC run_sampler() using the python multiprocessing package.
I can avoid this problem if at the beginning of my program I add:
At least, it doesn't then throw an error, and it appears to behave as expected.