fci_l1c_nc reader can't properly release file handle after reading under Windows
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.2k
- Forks
- 335
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 10
Description
Describe the bug
Just like the title said. Those nc files are still in lock so I can't move or delete them except for the last TRAIL part. Actually I'm not sure if it's a bug or just another nasty file handling problem in windows.
To Reproduce
Some ordinary satpy lines
scn = Scene(files=files)
scn.load([...])
scn.resample(...)
scn.save_dataset(...)
Temporary Solution
After done with your Scene object, try these lines:
for reader in scn._readers.values():
fhd = getattr(reader, "file_handlers", {})
for fhs in fhd.values():
for fh in fhs:
if hasattr(fh, "close"):
fh.close()
else:
h = getattr(fh, "file_handle", None)
if h is not None:
try:
h.close()
except Exception:
pass
fh.file_handle = None
They'll get every possible file handler in your Scene and close it so the files could be release. They work in my case at least.
Expected behavior
The file handles should be closed without further lines.
Environment Info:
- OS: Windows 11 24h2
- Satpy Version: 0.58
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the fci_l1c_nc reader and trace how its file handlers are owned and released through the Scene lifecycle. Reproduce on Windows using the provided Scene, load, resample, and save_dataset sequence, then verify the input files can be moved or deleted without the manual close workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100