Skip to content

File does not close #148

Open
Open
@Pierre-Louis-Boutruche

Description

@Pierre-Louis-Boutruche

When using Intake.open_netcdf('example.nc') and closing via ds.close(), the file is not closed, which causes problems when you want to delete the file in the program, for example.

In Intake-xarray/base.py

def close(self):
    """Delete open file from memory"""
    if self._ds is not None:
        self._ds.close() #Closes the file correctly
    self._ds = None
    self._schema = None

Without this modification, here's the error I get when I try to delete the netcdf file:
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'data_2024-07-31.nc'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions