From 6076a384cefed748b2302ab1ed6773153ced6cc1 Mon Sep 17 00:00:00 2001 From: Gregor Ronniger Date: Fri, 6 Mar 2026 14:45:30 +0100 Subject: [PATCH] use TemporaryDirectory while hashing gds files to avoid multi-process race conditions --- gplugins/common/utils/get_sparameters_path.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gplugins/common/utils/get_sparameters_path.py b/gplugins/common/utils/get_sparameters_path.py index 42654f45..cb54e918 100644 --- a/gplugins/common/utils/get_sparameters_path.py +++ b/gplugins/common/utils/get_sparameters_path.py @@ -3,6 +3,7 @@ import hashlib from functools import partial from pathlib import Path +from tempfile import TemporaryDirectory from typing import Any import gdsfactory as gf @@ -20,9 +21,9 @@ def get_kwargs_hash(**kwargs: Any) -> str: def get_component_hash(component: gf.Component) -> str: - gdspath = Path(component.write_gds(no_empty_cells=True, with_metadata=False)) - h = hashlib.md5(gdspath.read_bytes()).hexdigest() - gdspath.unlink() + with TemporaryDirectory() as tmpdir: + gdspath = Path(component.write_gds(gdsdir=tmpdir, no_empty_cells=True, with_metadata=False)) + h = hashlib.md5(gdspath.read_bytes()).hexdigest() return h