Add support for no `._first.value` update shm prepends
parent
8219307bf5
commit
09431aad85
piker/data
|
@ -40,10 +40,11 @@ log = get_logger(__name__)
|
|||
|
||||
# how much is probably dependent on lifestyle
|
||||
_secs_in_day = int(60 * 60 * 24)
|
||||
# we try for 3 times but only on a run-every-other-day kinda week.
|
||||
_default_size = 20 * _secs_in_day
|
||||
# we try for a buncha times, but only on a run-every-other-day kinda week.
|
||||
_days_worth = 16
|
||||
_default_size = _days_worth * _secs_in_day
|
||||
# where to start the new data append index
|
||||
_rt_buffer_start = int(9*_secs_in_day)
|
||||
_rt_buffer_start = int((_days_worth - 1) * _secs_in_day)
|
||||
|
||||
|
||||
def cuckoff_mantracker():
|
||||
|
@ -61,13 +62,12 @@ def cuckoff_mantracker():
|
|||
def ensure_running(self):
|
||||
pass
|
||||
|
||||
|
||||
# "know your land and know your prey"
|
||||
# https://www.dailymotion.com/video/x6ozzco
|
||||
mantracker._resource_tracker = ManTracker()
|
||||
mantracker.register = mantracker._resource_tracker.register
|
||||
mantracker.ensure_running = mantracker._resource_tracker.ensure_running
|
||||
ensure_running = mantracker._resource_tracker.ensure_running
|
||||
# ensure_running = mantracker._resource_tracker.ensure_running
|
||||
mantracker.unregister = mantracker._resource_tracker.unregister
|
||||
mantracker.getfd = mantracker._resource_tracker.getfd
|
||||
|
||||
|
@ -262,10 +262,10 @@ class ShmArray:
|
|||
|
||||
if fields:
|
||||
selection = array[fields]
|
||||
fcount = len(fields)
|
||||
# fcount = len(fields)
|
||||
else:
|
||||
selection = array
|
||||
fcount = len(array.dtype.fields)
|
||||
# fcount = len(array.dtype.fields)
|
||||
|
||||
# XXX: manual ``.view()`` attempt that also doesn't work.
|
||||
# uview = selection.view(
|
||||
|
@ -308,6 +308,7 @@ class ShmArray:
|
|||
|
||||
field_map: Optional[dict[str, str]] = None,
|
||||
prepend: bool = False,
|
||||
update_first: bool = True,
|
||||
start: Optional[int] = None,
|
||||
|
||||
) -> int:
|
||||
|
@ -320,10 +321,9 @@ class ShmArray:
|
|||
|
||||
'''
|
||||
length = len(data)
|
||||
index = start if start is not None else self._last.value
|
||||
|
||||
if prepend:
|
||||
index = self._first.value - length
|
||||
index = (start or self._first.value) - length
|
||||
|
||||
if index < 0:
|
||||
raise ValueError(
|
||||
|
@ -331,6 +331,9 @@ class ShmArray:
|
|||
f'You have passed {abs(index)} too many datums.'
|
||||
)
|
||||
|
||||
else:
|
||||
index = start if start is not None else self._last.value
|
||||
|
||||
end = index + length
|
||||
|
||||
if field_map:
|
||||
|
@ -348,12 +351,17 @@ class ShmArray:
|
|||
# tries to access ``.array`` (which due to the index
|
||||
# overlap will be empty). Pretty sure we've fixed it now
|
||||
# but leaving this here as a reminder.
|
||||
if prepend:
|
||||
if prepend and update_first:
|
||||
assert index < self._first.value
|
||||
|
||||
if index < self._first.value:
|
||||
if (
|
||||
index < self._first.value
|
||||
and update_first
|
||||
):
|
||||
assert prepend, 'prepend=True not passed but index decreased?'
|
||||
self._first.value = index
|
||||
else:
|
||||
|
||||
elif not prepend:
|
||||
self._last.value = end
|
||||
|
||||
self._post_init = True
|
||||
|
@ -389,6 +397,7 @@ class ShmArray:
|
|||
f"Input array has unknown field(s): {only_in_theirs}"
|
||||
)
|
||||
|
||||
# TODO: support "silent" prepends that don't update ._first.value?
|
||||
def prepend(
|
||||
self,
|
||||
data: np.ndarray,
|
||||
|
|
Loading…
Reference in New Issue