Skip to content
Snippets Groups Projects
Commit 3afd59bf authored by jkerdreu's avatar jkerdreu
Browse files

Change the way we push, now it's only periodic

git-svn-id: https://redmine.imt-atlantique.fr/svn/xaal/code/Python/trunk@2098 b32b6428-25c9-4566-ad07-03861ab6144f
parent dde8134b
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ import logging
PACKAGE_NAME = "xaal.warp10"
logger = logging.getLogger(PACKAGE_NAME)
# period between two push
PUSH_RATE = 60
DATA_BUF = ''
class WARP10Logger:
......@@ -27,9 +29,12 @@ class WARP10Logger:
dev.info = "%s@%s" % (PACKAGE_NAME,platform.node())
self.eng.add_device(dev)
self.http = urllib3.PoolManager()
self.eng.add_timer(self.push,PUSH_RATE)
def push(self):
global DATA_BUF
if len(DATA_BUF)==0:
return
try:
rsp = self.http.request('POST', self.cfg['url'],headers={'X-Warp10-Token':self.cfg['token']},body=DATA_BUF,retries=2)
except Exception:
......@@ -53,7 +58,6 @@ class WARP10Logger:
if value != None:
buf = buf +"%s// %s%s %s\n" % (now,name,tags,value)
DATA_BUF = DATA_BUF + buf
self.push()
def setup(engine):
WARP10Logger(engine)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment