From 4fbdbcde359c95a0c3073166a68b426529a7ecc3 Mon Sep 17 00:00:00 2001 From: Netkas Date: Fri, 15 Jan 2021 18:44:20 -0500 Subject: [PATCH] Updated warmup --- scripts/warmup.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/scripts/warmup.py b/scripts/warmup.py index 73e8b4bf..37b68010 100644 --- a/scripts/warmup.py +++ b/scripts/warmup.py @@ -102,6 +102,34 @@ def spamdetect(): print("[SPAMDETECT] Started successfully") +def emotion(): + print("[EMOTION] Warming up") + + current_tries = 0 + max_tries = 30 # 5 Minutes + while True: + if current_tries > max_tries: + print("[EMOTION] ERROR! Too many attempts") + sys.exit(1) + + try: + r = requests.post("http://127.0.0.1:5605/", data={"input": "The quick brown fox jumped over the lazy dog"}) + if r.status_code == 200: + print("[EMOTION] OK") + break + else: + print("[EMOTION] Failed, Returned status code {0}, '{1}'".format(str(r.status_code), r.text)) + except: + print("[EMOTION] Failed, request not completed") + pass + + print("[EMOTION] Waiting 10 seconds") + time.sleep(10) + current_tries += 1 + + print("[SPAMDETECT] Started successfully") + + def nsfw(): print("[NSFW] Warming up") @@ -154,6 +182,7 @@ print("CoffeeHouse-Utils Warmup") core_nlp() spamdetect() langdetect() +emotion() nsfw() print("OK, CoffeeHouse-Utils seems to be running fine.")