You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I reproduced this on macOS with rioxarray master, rasterio 1.5.1 and xarray 2026.7.0: one empty Error in sys.excepthook block for each open_rasterio() that is still open at exit.
It comes from rasterio 1.5, not rioxarray. The same script is silent with rasterio 1.4.3, and it reproduces with only xarray and rasterio: a CachingFileManager(rasterio.open, ...) left open at exit, with no rioxarray involved. xarray's atexit hook deliberately removes CachingFileManager.__del__, so datasets left in xarray's file cache are finalized very late, and rasterio 1.5's new DatasetBase.__del__ then tries to close them. rasterio #3563 was closed as fixed by rasterio #3612, but that fix is in 1.5.1 and this path still fails, so I've reported it upstream with a minimal reproducer: rasterio/rasterio#3646.
Until that's fixed, any of these avoids it:
# close explicitlydata=rioxarray.open_rasterio("geo_grid.tif")
...
data.close()
# or use a context managerwithrioxarray.open_rasterio("geo_grid.tif") asdata:
...
open_rasterio(..., lock=False) also didn't show the messages in my tests, but closing the dataset is the more robust fix.
Update: a fix is proposed in rasterio/rasterio#3647. With it, the original script above exits cleanly.
Activity
VolodymyrLinuxovich commentedon Sep 26, 2026
I reproduced this on macOS with rioxarray
master, rasterio 1.5.1 and xarray 2026.7.0: one emptyError in sys.excepthookblock for eachopen_rasterio()that is still open at exit.It comes from rasterio 1.5, not rioxarray. The same script is silent with rasterio 1.4.3, and it reproduces with only xarray and rasterio: a
CachingFileManager(rasterio.open, ...)left open at exit, with no rioxarray involved. xarray'satexithook deliberately removesCachingFileManager.__del__, so datasets left in xarray's file cache are finalized very late, and rasterio 1.5's newDatasetBase.__del__then tries to close them. rasterio #3563 was closed as fixed by rasterio #3612, but that fix is in 1.5.1 and this path still fails, so I've reported it upstream with a minimal reproducer: rasterio/rasterio#3646.Until that's fixed, any of these avoids it:
open_rasterio(..., lock=False)also didn't show the messages in my tests, but closing the dataset is the more robust fix.Update: a fix is proposed in rasterio/rasterio#3647. With it, the original script above exits cleanly.
jsta commentedon Sep 28, 2026
The above didn't work for me, and the linked PR was closed in rasterio for apparent AI policy violation.