debug
This commit is contained in:
parent
dd24d723bd
commit
21a1a7a0b8
19
main.py
19
main.py
|
@ -32,9 +32,11 @@ cors = CORS(app, resources={r"/api/predict": {"origins": url},
|
|||
r"/health": {"origins": "*"}
|
||||
})
|
||||
users = {}
|
||||
alive = "alive"
|
||||
|
||||
def vre_fetch():
|
||||
while True:
|
||||
try:
|
||||
time.sleep(1000)
|
||||
print('getting new material')
|
||||
#users[token]['args']['vre'].get_vre_update()
|
||||
|
@ -45,32 +47,45 @@ def vre_fetch():
|
|||
vre.index_periodic_update()
|
||||
rg.update_index(vre.get_index())
|
||||
rg.update_db(vre.get_db())
|
||||
except Exception as e:
|
||||
alive = "dead_vre_fetch"
|
||||
|
||||
|
||||
|
||||
def user_interest_decay(token):
|
||||
while True:
|
||||
try:
|
||||
if token in users:
|
||||
print("decaying interests after 3 minutes for " + users[token]['username'])
|
||||
time.sleep(180)
|
||||
users[token]['user'].decay_interests()
|
||||
else:
|
||||
break
|
||||
except Exception as e:
|
||||
alive = "dead_interest_decay"
|
||||
|
||||
|
||||
def clear_inactive():
|
||||
while True:
|
||||
try:
|
||||
time.sleep(1)
|
||||
for username in users:
|
||||
if users[username]['activity'] > 3600:
|
||||
del users[username]
|
||||
users[username]['activity'] += 1
|
||||
except Exception as e:
|
||||
alive = "dead_clear_inactive"
|
||||
|
||||
@app.route("/health", methods=['GET'])
|
||||
def health():
|
||||
if alive=="alive":
|
||||
return "Success", 200
|
||||
else:
|
||||
return alive, 500
|
||||
|
||||
@app.route("/api/dm", methods=['POST'])
|
||||
def init_dm():
|
||||
try:
|
||||
token = request.get_json().get("token")
|
||||
status = request.get_json().get("stat")
|
||||
if status == "start":
|
||||
|
@ -94,6 +109,10 @@ def init_dm():
|
|||
else:
|
||||
message = {"stat": "done"}
|
||||
return message
|
||||
except Exception as e:
|
||||
message = {"stat": "init_dm_error"}
|
||||
return message
|
||||
|
||||
|
||||
@app.route("/api/predict", methods=['POST'])
|
||||
def predict():
|
||||
|
|
Loading…
Reference in New Issue