From 71ca4c8e1f5425c66064669a1f6bd3d5976c31f2 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 11 Jan 2023 11:05:24 -0500 Subject: [PATCH] Use actor uid in shm keys for rt quote buffers Allows running simultaneous data feed services on the same (linux) host by avoiding file-name collisions instead keying shm buffer sets by the given `brokerd` instance. This allows, for example, either multiple dev versions of the data layer to run side-by-side or for the test suite to be seamlessly run alongside a production instance. --- piker/data/feed.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/piker/data/feed.py b/piker/data/feed.py index cc287d40..88e9ceed 100644 --- a/piker/data/feed.py +++ b/piker/data/feed.py @@ -786,11 +786,14 @@ async def manage_history( # from tractor._state import _runtime_vars # port = _runtime_vars['_root_mailbox'][1] + uid = tractor.current_actor().uid + suffix = '.'.join(uid) + # (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( # key=f'{fqsn}_hist_p{port}', - key=f'{fqsn}_hist', + key=f'{fqsn}_hist.{suffix}', # use any broker defined ohlc dtype: dtype=getattr(mod, '_ohlc_dtype', base_iohlc_dtype), @@ -808,7 +811,7 @@ async def manage_history( rt_shm, opened = maybe_open_shm_array( # key=f'{fqsn}_rt_p{port}', - key=f'{fqsn}_rt', + key=f'{fqsn}_rt.{suffix}', # use any broker defined ohlc dtype: dtype=getattr(mod, '_ohlc_dtype', base_iohlc_dtype),