Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Feldman-Cousins examples #2128

Merged
merged 3 commits into from May 7, 2019
Merged

Fix Feldman-Cousins examples #2128

merged 3 commits into from May 7, 2019

Conversation

@dlennarz
Copy link
Contributor

@dlennarz dlennarz commented Apr 30, 2019

I noticed that the Feldman-Cousins examples stopped working with a newer installation of Python. The reason is that multiprocessing now needs the code to be enclosed by "if name == 'main':", otherwise it will lock up and never finish.

I also added back the astropy ProgressBar.

dlennarz added 3 commits Apr 30, 2019
I noticed that the Feldman-Cousins examples stopped working with a newer installation of Python. The reason is that multiprocessing now needs the code to be enclosed by "if __name__ == '__main__':", otherwise it will lock up and never finish.

I also added back the astropy ProgressBar.
PEP 8:  avoid trailing whitespace anywhere
@adonath adonath self-requested a review May 2, 2019
@adonath
Copy link
Member

@adonath adonath commented May 2, 2019

Thanks, @dlennarz! I just checked and the current examples just work fine for me in Python 3.7 and the Gammapy 0.11 environment. It would be nice if you could give some more info which error you see. For this it would be also helpful to have the output of the $ gammapy info command.

However the changes look good to me and could be merged once we understood, why you see an error...

@adonath adonath self-assigned this May 2, 2019
@adonath adonath added the docs label May 2, 2019
@adonath adonath added this to the 0.12 milestone May 2, 2019
@dlennarz
Copy link
Contributor Author

@dlennarz dlennarz commented May 2, 2019

Hi @adonath, Upon closer investigation, it turns out that the problem was not a newer installation of Python, but running the code from Windows. For details see here:
https://stackoverflow.com/questions/20222534/python-multiprocessing-on-windows-if-name-main

The important part is this one:
"Since Windows has no fork, the multiprocessing module starts a new Python process and imports the calling module. If Process() gets called upon import, then this sets off an infinite succession of new processes (or until your machine runs out of resources)."

I had originally developed this code under Linux and hence never noticed that it wouldn't run under Windows.

@adonath adonath merged commit 54ffb2a into gammapy:master May 7, 2019
9 checks passed
@adonath
Copy link
Member

@adonath adonath commented May 7, 2019

Thanks for the explanation @dlennarz. No further comments from my side...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants