Registry Mirror
Skip to content

Conversation

@nightcityblade

Copy link
Copy Markdown
Contributor

Description

Dataset.copy() currently drops the dataset's resource-closing callback even though the copied lazy variables can still access the same backend. If the original dataset is closed and the copy later reopens the file while loading, copied.close() cannot release that handle.

Preserve the callback on copies so either dataset can close a reopened backend resource. The regression test covers closing both the original dataset and its copy.

Checklist

AI Disclosure

@nightcityblade

Copy link
Copy Markdown
Contributor Author

This replaces #11642, which GitHub could not reopen after its head history was repaired during CI follow-up. The implementation remains the same focused three-file change; the regression test now explicitly annotates its callback-tracking list to satisfy Mypy. Focused validation: python3 -m pytest -q -o addopts="" xarray/tests/test_dataset.py -k copy_preserves_close (1 passed).

@dcherian
dcherian merged commit 7e7d575 into pydata:main Sep 30, 2026
44 checks passed
@welcome

welcome Bot commented Sep 30, 2026

Copy link
Copy Markdown

Congratulations on completing your first pull request! Welcome to Xarray! We are proud of you, and hope to see you again! celebration gif

@TomNicholas TomNicholas mentioned this pull request Sep 30, 2026
TomNicholas added a commit that referenced this pull request Sep 30, 2026
Add a v2026.09.1 section and move the #11643 entry, which was merged into the already-released v2026.09.0 section.
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.

load after close automatically reopens, but doesn't close everything

2 participants