diff --git a/piker/fsp/_api.py b/piker/fsp/_api.py index 92f8f271..bb2dea50 100644 --- a/piker/fsp/_api.py +++ b/piker/fsp/_api.py @@ -200,9 +200,13 @@ def maybe_mk_fsp_shm( ) # (attempt to) uniquely key the fsp shm buffers + # Use hash for macOS compatibility (31 char limit) + import hashlib actor_name, uuid = tractor.current_actor().uid - uuid_snip: str = uuid[:16] - key: str = f'piker.{actor_name}[{uuid_snip}].{sym}.{target.name}' + # Create short hash of sym and target name + content = f'{sym}.{target.name}' + content_hash = hashlib.md5(content.encode()).hexdigest()[:8] + key: str = f'{uuid[:8]}_{content_hash}.fsp' shm, opened = maybe_open_shm_array( key, diff --git a/piker/tsp/_history.py b/piker/tsp/_history.py index 99261342..a5073933 100644 --- a/piker/tsp/_history.py +++ b/piker/tsp/_history.py @@ -32,6 +32,7 @@ from __future__ import annotations from datetime import datetime from functools import partial from pathlib import Path +import platform from pprint import pformat from types import ModuleType from typing import ( @@ -1380,13 +1381,20 @@ async def manage_history( service: str = name.rstrip(f'.{mod.name}') fqme: str = mkt.get_fqme(delim_char='') + key: str = f'piker.{service}[{uuid[:16]}].{fqme}' + # use a short hash of the `fqme` to deal with macOS + # file-name-len limit.. + if platform.system() == 'Darwin': + import hashlib + fqme_hash: str = hashlib.md5(fqme.encode()).hexdigest()[:8] + key: str = f'{uuid[:8]}_{fqme_hash}' + # (maybe) allocate shm array for this broker/symbol which will # be used for fast near-term history capture and processing. hist_shm, opened = maybe_open_shm_array( size=_default_hist_size, append_start_index=_hist_buffer_start, - - key=f'piker.{service}[{uuid[:16]}].{fqme}.hist', + key=f'{key}.hist', # use any broker defined ohlc dtype: dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields), @@ -1405,7 +1413,7 @@ async def manage_history( rt_shm, opened = maybe_open_shm_array( size=_default_rt_size, append_start_index=_rt_buffer_start, - key=f'piker.{service}[{uuid[:16]}].{fqme}.rt', + key=f'{key}.rt', # use any broker defined ohlc dtype: dtype=getattr(mod, '_ohlc_dtype', def_iohlcv_fields),