1 id + locks + live : more frequent, last known points, already sent points + ms points + fixed jump time

This commit is contained in:
l_samenv
2024-08-16 09:55:30 +02:00
parent f4cf8fd9a5
commit 9e08f47916
5 changed files with 83 additions and 73 deletions

View File

@@ -21,7 +21,7 @@ import seagraph
import traceback
import logging
import circularlog
from gevent.lock import RLock
import os
import signal
@@ -81,6 +81,7 @@ def get_update(path=None):
yield to_json_sse(msg)
if messages:
lastmsg = time.time()
gevent.sleep(0.1)
else:
if time.time() > lastmsg + 30:
if not client.info():
@@ -292,13 +293,15 @@ class SeaInstrument(Instrument):
self.seacmd = None
self.last_client_remove = time.time()
self.history = deque(maxlen=1000)
self.sea_lock = RLock()
self.init()
gevent.Greenlet.spawn(self.checkconnections)
def init(self):
self.values = {}
self.groups = {}
self.device = sea_request_reply(self.seaspy, "samenv name")[0] # first line
with self.sea_lock:
self.device = sea_request_reply(self.seaspy, "samenv name")[0] # first line
self.consolepos = 0
self.timeStamp = None
self.history.clear()
@@ -344,7 +347,8 @@ class SeaInstrument(Instrument):
gobj.lastreq = now
gobj.lastpoll = now
try:
data = sea_request_reply(self.seaspy, 'getgroup '+path)
with self.sea_lock:
data = sea_request_reply(self.seaspy, 'getgroup '+path)
except Exception as e:
logging.error('ERROR (getgroup %s) %s', path, traceback.format_exc())
continue
@@ -611,7 +615,7 @@ class SeaParams:
self.consolepos = 0
self.id = uuid.uuid4().hex[0:15]
# SeaGraph.__init__(self)
self.queue = [dict(type='id', id=self.id, instrument=instrument.inst_name, device=instrument.device)]
self.queue = []
def poll(self):
messages = self.queue