From c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5 Mon Sep 17 00:00:00 2001 From: Théo de la Hogue Date: Tue, 16 Jan 2024 12:53:21 +0100 Subject: Adding a new timestamp attribute to SharedObject class. --- src/argaze/DataStructures.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/argaze/DataStructures.py b/src/argaze/DataStructures.py index d3b6544..cf5bc3a 100644 --- a/src/argaze/DataStructures.py +++ b/src/argaze/DataStructures.py @@ -13,7 +13,8 @@ import collections import json import ast import bisect -import threading, traceback, sys +import threading +import math import pandas import numpy @@ -105,6 +106,7 @@ class SharedObject(): def __init__(self): self._lock = threading.Lock() + self._timestamp = math.nan def acquire(self): self._lock.acquire() @@ -115,11 +117,17 @@ class SharedObject(): def locked(self) -> bool: return self._lock.locked() - def __enter__(self): - self.acquire() + @property + def timestamp(self) -> int|float: + """Get timestamp""" + + return self._timestamp + + @timestamp.setter + def timestamp(self, timestamp: int|float): + """Set timestamp""" - def __exit__(self, type, value, traceback): - self.release() + self._timestamp = timestamp class TimeStampedBuffer(collections.OrderedDict): """Ordered dictionary to handle timestamped data. -- cgit v1.1