minor logic problems
This commit is contained in:
parent
1f6487237a
commit
5ec387e097
|
@ -28,9 +28,11 @@ app = f("web")
|
||||||
h2 = timedelta(hours=2)
|
h2 = timedelta(hours=2)
|
||||||
|
|
||||||
def interceptor(request, response): # A response interceptor takes two args
|
def interceptor(request, response): # A response interceptor takes two args
|
||||||
|
global lastUpdate
|
||||||
if 'ws-travis.dus.com/socket.io/?EIO=3&transport=polling' in request.url :
|
if 'ws-travis.dus.com/socket.io/?EIO=3&transport=polling' in request.url :
|
||||||
body = decode(response.body, response.headers.get('Content-Encoding', 'identity'))
|
body = decode(response.body, response.headers.get('Content-Encoding', 'identity'))
|
||||||
x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8"))
|
x = re.split("\d\d\d:\d\d\/dus,", body.decode("utf-8"))
|
||||||
|
lastUpdate = datetime.now(timezone.utc)
|
||||||
for i in [i for i in x if i]:
|
for i in [i for i in x if i]:
|
||||||
try:
|
try:
|
||||||
j = json.loads(i)
|
j = json.loads(i)
|
||||||
|
@ -121,7 +123,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
# loop and restart with restartWait Interval
|
# loop and restart with restartWait Interval
|
||||||
while True:
|
while True:
|
||||||
sleep(10)
|
sleep(30)
|
||||||
if datetime.now(timezone.utc) > lastaccess + restartWait:
|
if datetime.now(timezone.utc) > lastaccess + restartWait:
|
||||||
d1 = createDriver()
|
d1 = createDriver()
|
||||||
d1.get('https://dus-travis.dus.com/')
|
d1.get('https://dus-travis.dus.com/')
|
||||||
|
@ -140,10 +142,14 @@ if __name__ == '__main__':
|
||||||
lastaccess = datetime.now(timezone.utc)
|
lastaccess = datetime.now(timezone.utc)
|
||||||
|
|
||||||
l = filter(idIsRecent,list(valuestore.keys()))
|
l = filter(idIsRecent,list(valuestore.keys()))
|
||||||
if len(list(l)) < 1:
|
if len(list(l)) < 1 and lastUpdate < datetime.now(timezone.utc) - timedelta(seconds=90):
|
||||||
restartWait = timedelta(seconds=60)
|
restartWait = timedelta(minutes=3)
|
||||||
|
print ("Something stupid happened, setting interval to 3m")
|
||||||
else:
|
else:
|
||||||
|
if restartWait < timedelta(hours=1):
|
||||||
restartWait = timedelta(hours=4)
|
restartWait = timedelta(hours=4)
|
||||||
|
print ("Something stupid normalized, resetting interval to 4h")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue