Skip to content

Commit

Permalink
Use pyMilk for reading CACAO streams on Python.
Browse files Browse the repository at this point in the history
  • Loading branch information
ehpor committed Nov 12, 2024
1 parent ae80cfb commit 7c6d591
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions catkit2/testbed/service_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,26 @@ def __init__(self, testbed, service_id):
# The import is here instead of at the top of the file to avoid circular imports.
from .testbed_proxy import TestbedProxy # noqa: E402
object.__setattr__(self, '_testbed', TestbedProxy(getattr(super(), 'testbed').host, getattr(super(), 'testbed').port))
object.__setattr__(self, '_cacao_streams', {})

@property
def testbed(self):
return self._testbed

def get_cacao_stream(self, name):
try:
from pyMilk.interfacing.isio_shmlib import SHM

# Load cacao stream if we didn't already open it.
if name not in self._cacao_streams:
shm_name = self.cacao_stream_names[name]
stream = SHM(shm_name)
self._cacao_streams[name] = stream

return self._cacao_streams[name]
except ImportError as e:
raise RuntimeError("pyMilk install is required for using CACAO streams.") from e

def __getattr__(self, name):
'''Get a property, command or data stream.
Expand Down

0 comments on commit 7c6d591

Please sign in to comment.