gtfsrt_concepcion/sync.py

22 lines
621 B
Python

# coding: utf-8
from updater.model.feed import init_db, db, engine
from updater.main import sync_db, log, estado_maximo
import time
import random
if __name__ == '__main__':
init_db(db, engine)
doki = int(time.time()) + 600
time.sleep(random.randint(1, 30)) #random wait
while True:
if not sync_db():
i = int(time.time())
if i >= doki:
doki = i + 600
log.info('Heartbeat')
if estado_maximo == 0:
time.sleep(random.randint(10, 30)) #more randomness
else:
doki = int(time.time()) + 600