From 1b38628b09c853ca906cb541f48dab5f04d4f1c6 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 24 May 2022 10:36:17 -0400 Subject: [PATCH] Handle teardown race, add comment about shm subdirs --- piker/data/_sharedmem.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/piker/data/_sharedmem.py b/piker/data/_sharedmem.py index 8848ec1c..47d58d3e 100644 --- a/piker/data/_sharedmem.py +++ b/piker/data/_sharedmem.py @@ -98,7 +98,12 @@ class SharedInt: if _USE_POSIX: # We manually unlink to bypass all the "resource tracker" # nonsense meant for non-SC systems. - shm_unlink(self._shm.name) + name = self._shm.name + try: + shm_unlink(name) + except FileNotFoundError: + # might be a teardown race here? + log.warning(f'Shm for {name} already unlinked?') class _Token(BaseModel): @@ -536,6 +541,10 @@ def attach_shm_array( if key in _known_tokens: assert _Token.from_msg(_known_tokens[key]) == token, "WTF" + # XXX: ugh, looks like due to the ``shm_open()`` C api we can't + # actually place files in a subdir, see discussion here: + # https://stackoverflow.com/a/11103289 + # attach to array buffer and view as per dtype shm = SharedMemory(name=key) shmarr = np.ndarray(