Compare commits

...

1 Commits

Author SHA1 Message Date
Ryan Schultz 46640722b4 Fix PermissionError deleting locked HDF5 cache on Windows
When the hdf5 serializer constructor fails on an existing
file, the HDF5 C library retains the file handle on Windows.
Force gc.collect() before os.remove() to release it, and
catch PermissionError to skip the cache gracefully if the
file is still locked.

Generated with the assistance of an AI coding tool.
2026-03-29 09:51:15 -05:00
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -18,6 +18,7 @@
from __future__ import annotations
import gc
import hashlib
import os
import shutil
@@ -170,7 +171,13 @@ class IfcStore:
# No point to trying again the same operation.
return
os.remove(IfcStore.cache_path)
# Force GC to release any dangling HDF5 C-level file handle (Windows).
gc.collect()
try:
os.remove(IfcStore.cache_path)
except PermissionError as e:
print(f"Could not delete locked cache file '{cache_path.name}': {str(e)}. Skipping cache.")
return
try:
IfcStore.cache = ifcopenshell.geom.serializers.hdf5(
IfcStore.cache_path, cache_settings, serializer_settings
+1
View File
@@ -25,6 +25,7 @@ import bmesh
import bpy
import mathutils
import numpy as np
from bpy_extras import view3d_utils
from mathutils import Vector
import bonsai.core.tool