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

Conversation

Projects
None yet
2 participants
@dlennarz
Copy link
Contributor

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 some commits Apr 30, 2019

Fix Feldman-Cousins examples
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.
Remove trailing spaces
PEP 8:  avoid trailing whitespace anywhere

@adonath adonath self-requested a review May 2, 2019

@adonath

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

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

Codacy/PR Quality Review Up to standards. A positive pull request.
Details
Scrutinizer Analysis: No new issues – Tests: passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
gammapy.gammapy Build #20190430.6 succeeded
Details
gammapy.gammapy (DevDocs) DevDocs succeeded
Details
gammapy.gammapy (Lint) Lint succeeded
Details
gammapy.gammapy (Test Python35) Test Python35 succeeded
Details
gammapy.gammapy (Test Windows35) Test Windows35 succeeded
Details
gammapy.gammapy (Test Windows37) Test Windows37 succeeded
Details
@adonath

This comment has been minimized.

Copy link
Member

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
You can’t perform that action at this time.