html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/7880#issuecomment-1572412059,https://api.github.com/repos/pydata/xarray/issues/7880,1572412059,IC_kwDOAMm_X85duRqb,1217238,2023-06-01T16:51:07Z,2023-06-01T17:10:49Z,MEMBER,"Given that this error only is caused when Python is shutting down, which is exactly a case in which we do _not_ need to clean up open file objects, maybe we can remove the `__del__` instead?
Something like:
```python
import atexit
@atexit.register
def _remove_del_method():
# We don't need to close unclosed files at program exit,
# and may not be able to do, because Python is cleaning up
# imports.
del CachingFileManager.__del__
```
(I have not tested this!)","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1572437423,https://api.github.com/repos/pydata/xarray/issues/7880,1572437423,IC_kwDOAMm_X85duX2v,14808389,2023-06-01T17:01:56Z,2023-06-01T17:06:06Z,MEMBER,"that appears to work on both my laptop and my local HPC, and is arguably a lot easier to implement / understand as we don't need to make sure all the globals we use are still available (which in this case would be `acquire`, `OPTIONS`, `warnings`, and `RuntimeWarning`).
Edit: let me change the PR to do that instead","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1572384036,https://api.github.com/repos/pydata/xarray/issues/7880,1572384036,IC_kwDOAMm_X85duK0k,14808389,2023-06-01T16:38:23Z,2023-06-01T16:54:08Z,MEMBER,"> Have you verfied that this fixes things at least on your machine?
I thought I did, but apparently something changed: right now it fails because `OPTIONS` is not available anymore, so we might have to add a reference to that, as well. Additionally, for the warning we use `warnings.warn` and `RuntimeWarning` that might also have disappeared already (but those are standard library / builtins, so hopefully not?)
In any case, you can verify this, too:
- create a new environment using `mamba create -n test python=3.11 numpy pandas packaging pooch netcdf4` and activate it
- run `pip install 'dask[array]'` to install `dask` without `distributed` (this appears to make a difference for me, not sure if that's the same elsewhere)
- editable-install `xarray` so we can easily switch between branches
- run `python -c 'import xarray as xr; ds = xr.tutorial.open_dataset(""air_temperature"", chunks={})'`
This should print an error for `main` and shouldn't with this branch (confirmed on my local HPC).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1572363440,https://api.github.com/repos/pydata/xarray/issues/7880,1572363440,IC_kwDOAMm_X85duFyw,14808389,2023-06-01T16:26:42Z,2023-06-01T16:26:42Z,MEMBER,"the issue is that this doesn't occur on normal garbage collection but only on interpreter shutdown. So really, I don't think we have any way to test this using `pytest` as that itself is written in python (unless of course we can make use of sub-interpreters, but that might be more trouble than it's worth).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1572359754,https://api.github.com/repos/pydata/xarray/issues/7880,1572359754,IC_kwDOAMm_X85duE5K,43316012,2023-06-01T16:23:45Z,2023-06-01T16:23:45Z,COLLABORATOR,"Maybe you can add a test that creates a cachingFilemanager object, then deletes it, then run `gc.collect()` and check somehow if it works? But no idea how pytest interferes with this or how you can ensure that there are no references to the module anymore?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1572350143,https://api.github.com/repos/pydata/xarray/issues/7880,1572350143,IC_kwDOAMm_X85duCi_,1217238,2023-06-01T16:16:40Z,2023-06-01T16:16:40Z,MEMBER,"I agree that this seems very hard to test!
Have you verfied that this fixes things at least on your machine?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1567450094,https://api.github.com/repos/pydata/xarray/issues/7880,1567450094,IC_kwDOAMm_X85dbWPu,43316012,2023-05-29T19:28:21Z,2023-05-29T19:28:21Z,COLLABORATOR,"> I think this is intended (though certainly not very easy to get right): see the second part of the [warning in the `__del__` documentation](https://docs.python.org/3/reference/datamodel.html#object.__del__).
You are right, that warning is exactly what is causing the issues.","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1567446747,https://api.github.com/repos/pydata/xarray/issues/7880,1567446747,IC_kwDOAMm_X85dbVbb,14808389,2023-05-29T19:22:12Z,2023-05-29T19:22:12Z,MEMBER,"> I would have thought that the global (or module level here) variable/function aquire should have at least one reference until after the deletion of the object.
I think this is intended (though certainly not very easy to get right): see the second part of the [warning in the `__del__` documentation](https://docs.python.org/3/reference/datamodel.html#object.__del__).","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352
https://github.com/pydata/xarray/pull/7880#issuecomment-1567439206,https://api.github.com/repos/pydata/xarray/issues/7880,1567439206,IC_kwDOAMm_X85dbTlm,43316012,2023-05-29T19:09:41Z,2023-05-29T19:09:41Z,COLLABORATOR,"That's quite a weird bug. I would have thought that the global (or module level here) variable/function aquire should have at least one reference until after the deletion of the object.
Is that a bug in pythons garbage collection?
Or does the garbage collection already start when calling `del` and does not wait for the completion of the `__del__` method?","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1730664352