Add changed timeseries to queue
This commit is contained in:
parent
1e034f1a7f
commit
caeaa0bf73
|
@ -9,6 +9,7 @@ import time
|
|||
|
||||
class LTS:
|
||||
base_dir = "data"
|
||||
queue_dir = "queue"
|
||||
limit = 1000
|
||||
|
||||
def __init__(self, description=None, id=None):
|
||||
|
@ -20,6 +21,7 @@ class LTS:
|
|||
m.update(bytes(serialized_description, encoding="UTF-8"))
|
||||
id = m.hexdigest()
|
||||
self.filename = self.base_dir + "/" + id
|
||||
self.id = id
|
||||
try:
|
||||
with open(self.filename, "r") as fh:
|
||||
fcntl.flock(fh, fcntl.LOCK_SH)
|
||||
|
@ -57,6 +59,8 @@ class LTS:
|
|||
fcntl.flock(fh, fcntl.LOCK_EX)
|
||||
json.dump({"description": self.description, "data": self.data}, fh)
|
||||
fh.truncate()
|
||||
with open(self.queue_dir + "/" + self.id, "w") as fh:
|
||||
pass
|
||||
|
||||
def rebuild_index(self):
|
||||
t0 = time.time()
|
||||
|
|
Loading…
Reference in New Issue