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

Crash on import when running in parallel #170

Closed
leouieda opened this issue May 8, 2020 · 1 comment · Fixed by #171
Closed

Crash on import when running in parallel #170

leouieda opened this issue May 8, 2020 · 1 comment · Fixed by #171
Labels
bug Report a problem that needs to be fixed

Comments

@leouieda
Copy link
Member

leouieda commented May 8, 2020

Description of the problem

We recommend a workflow of keeping a Pooch as a global variable by calling pooch.create at import time. This is problematic when running in parallel and the cache folder has not been created yet. Each parallel process/thread will try to create it at the same time leading to a crash.

For our users, this is particularly bad since their packages crash on import even if there is no use of the sample datasets.

Not sure exactly what we can do on our end except:

  1. Add a warning in the docs about this issue.
  2. Change our recommended workflow to wrapping pooch.create in a function. This way the crash wouldn't happen at import but only when trying to fetch a dataset in parallel. This gives packages a chance to warn users not to load sample data for the first time in parallel.

Perhaps an ideal solution would be for Pooch to create the cache folder at install time. But that would mean hooking into setup.py (which is complicated) and I don't know if we could even do this with conda.

Full code that generated the error

See scikit-image/scikit-image#4660

@leouieda
Copy link
Member Author

leouieda commented May 8, 2020

We might also want to have tests in place for running some things in parallel. It will certainly help finding more places where this comes up (though dealing with parallel IO will not be fun).

leouieda added a commit that referenced this issue May 9, 2020
Add `exist_ok` to `os.makedirs` in case the cache folder is being created 
in parallel (multiple jobs trying to call `makedirs` at the same time). 
Includes a test case with threads and processes to make sure it works.

Fixes #170 and fixes #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report a problem that needs to be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant