diff --git a/masque/file/gdsii.py b/masque/file/gdsii.py index c20200c..f589ad8 100644 --- a/masque/file/gdsii.py +++ b/masque/file/gdsii.py @@ -617,7 +617,12 @@ def load_libraryfile( stream = mmap.mmap(base_stream.fileno(), 0, access=mmap.ACCESS_READ) # type: ignore else: stream = path.open(mode='rb') # noqa: SIM115 - return load_library(stream, full_load=full_load, postprocess=postprocess) + + try: + return load_library(stream, full_load=full_load, postprocess=postprocess) + finally: + if full_load: + stream.close() def check_valid_names(