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

Close files when CachingFileManager is garbage collected #2595

Merged
merged 22 commits into from
Dec 23, 2018

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Dec 9, 2018

This frees users from needing to worry about this.

Using __del__ turned up to be easier than using weak references.

@pep8speaks
Copy link

pep8speaks commented Dec 9, 2018

Hello @shoyer! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on December 23, 2018 at 19:51 Hours UTC

Fixes GH2560

This frees users from needing to worry about this.
@shoyer
Copy link
Member Author

shoyer commented Dec 11, 2018

Of course everything runs fine either on my laptop (Macbook) or work machine (Linux). I wonder what's going on with Travis-CI here.

@shoyer
Copy link
Member Author

shoyer commented Dec 13, 2018

@pydata/xarray It would be great if someone else could take a look at this, though certainly thread-safety and garbage collection are slightly painful concepts to think deeply about. If nobody reviews this, I will probably self-merge in a few days.

# - threading.Lock on Python 2.
# - dask.SerializableLock with dask v1.0.0 or earlier.
# - multiprocessing.Lock calls the argument "block" instead.
return lock.acquire(blocking)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the date, do you think its useful here to consider this Python 2 work around? I guess its the same work-around as the dask/multiprocessing issue.

@shoyer
Copy link
Member Author

shoyer commented Dec 15, 2018 via email

@shoyer
Copy link
Member Author

shoyer commented Dec 21, 2018

OK, I'm actually going to merge soon (and issue the 0.11.1 release) unless I hear any objections...

@shoyer shoyer merged commit c2ce5ea into pydata:master Dec 23, 2018
@shoyer shoyer deleted the file-manager-del branch December 23, 2018 20:11
dcherian pushed a commit to yohai/xarray that referenced this pull request Jan 2, 2019
* master:
  DEP: drop python 2 support and associated ci mods (pydata#2637)
  TST: silence warnings from bottleneck (pydata#2638)
  revert to dev version
  DOC: fix docstrings and doc build for 0.11.1
  Source encoding always set when opening datasets (pydata#2626)
  Add flake check to travis (pydata#2632)
  Fix dayofweek and dayofyear attributes from dates generated by cftime_range (pydata#2633)
  silence import warning (pydata#2635)
  fill_value in shift (pydata#2470)
  Flake fixed (pydata#2629)
  Allow passing of positional arguments in `apply` for Groupby objects (pydata#2413)
  Fix failure in time encoding for pandas < 0.21.1 (pydata#2630)
  Fix multiindex selection (pydata#2621)
  Close files when CachingFileManager is garbage collected (pydata#2595)
  added some logic to deal with rasterio objects in addition to filepaths (pydata#2589)
  Get 0d slices of ndarrays directly from indexing (pydata#2625)
  FIX Don't raise a deprecation warning for xarray.ufuncs.{angle,iscomplex} (pydata#2615)
  CF: also decode time bounds when available (pydata#2571)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants