-
Notifications
You must be signed in to change notification settings - Fork 321
Open
Open
Copy link
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 = NoneThey'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
Metadata
Metadata
Assignees
Labels
No labels