Add field diffing on failed push
parent
757f02e6f7
commit
4fe8c4487a
|
@ -194,9 +194,30 @@ class ShmArray:
|
||||||
# TODO: use .index for actual ring logic?
|
# TODO: use .index for actual ring logic?
|
||||||
index = self._i.value
|
index = self._i.value
|
||||||
end = index + length
|
end = index + length
|
||||||
self._array[index:end] = data[:]
|
try:
|
||||||
self._i.value = end
|
self._array[index:end] = data[:]
|
||||||
return end
|
self._i.value = end
|
||||||
|
return end
|
||||||
|
except ValueError as err:
|
||||||
|
# reraise with any field discrepancy
|
||||||
|
our_fields, their_fields = (
|
||||||
|
set(self._array.dtype.fields),
|
||||||
|
set(data.dtype.fields),
|
||||||
|
)
|
||||||
|
|
||||||
|
only_in_ours = our_fields - their_fields
|
||||||
|
only_in_theirs = their_fields - our_fields
|
||||||
|
|
||||||
|
if only_in_ours:
|
||||||
|
raise TypeError(
|
||||||
|
f"Input array is missing field(s): {only_in_ours}"
|
||||||
|
)
|
||||||
|
elif only_in_theirs:
|
||||||
|
raise TypeError(
|
||||||
|
f"Input array has unknown field(s): {only_in_theirs}"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
raise err
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
self._i._shm.close()
|
self._i._shm.close()
|
||||||
|
@ -214,7 +235,7 @@ class ShmArray:
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
_lotsa_5s = int(5*60*60*10/5)
|
_lotsa_5s = int(5 * 60 * 60 * 10 / 5)
|
||||||
|
|
||||||
|
|
||||||
def open_shm_array(
|
def open_shm_array(
|
||||||
|
|
Loading…
Reference in New Issue