From 55772efb34b01ab633edd8e9d9771ae010ad5748 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Fri, 3 Jun 2022 10:18:32 -0400 Subject: [PATCH] Bleh, try avoiding the too many files bug-thing.. --- piker/data/_sharedmem.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/piker/data/_sharedmem.py b/piker/data/_sharedmem.py index 47d58d3e..1172fc7b 100644 --- a/piker/data/_sharedmem.py +++ b/piker/data/_sharedmem.py @@ -20,6 +20,7 @@ NumPy compatible shared memory buffers for real-time IPC streaming. """ from __future__ import annotations from sys import byteorder +import time from typing import Optional from multiprocessing.shared_memory import SharedMemory, _USE_POSIX @@ -546,7 +547,21 @@ def attach_shm_array( # https://stackoverflow.com/a/11103289 # attach to array buffer and view as per dtype - shm = SharedMemory(name=key) + _err: Optional[Exception] = None + for _ in range(3): + try: + shm = SharedMemory( + name=key, + create=False, + ) + break + except OSError as oserr: + _err = oserr + time.sleep(0.1) + else: + if _err: + raise _err + shmarr = np.ndarray( (size,), dtype=token.dtype,