diff options
author | Théo de la Hogue | 2024-01-16 12:53:21 +0100 |
---|---|---|
committer | Théo de la Hogue | 2024-01-16 12:53:21 +0100 |
commit | c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5 (patch) | |
tree | a999c724ef3c0270a5276f38b781a8091359d43b | |
parent | 777a8438ebf225da99aaf2624b9d28b0680f7d5b (diff) | |
download | argaze-c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5.zip argaze-c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5.tar.gz argaze-c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5.tar.bz2 argaze-c8cdc1c013c4e9286f6c8d4d8469faf4411b7ab5.tar.xz |
Adding a new timestamp attribute to SharedObject class.
-rw-r--r-- | src/argaze/DataStructures.py | 18 |
1 files 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. |