Update app.py
Browse files
app.py
CHANGED
|
@@ -32,8 +32,14 @@ def warmer():
|
|
| 32 |
print("NO INTERNET")
|
| 33 |
print(str(e))
|
| 34 |
|
|
|
|
| 35 |
def restart():
|
|
|
|
| 36 |
while True:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
try:
|
| 38 |
text_output,image_output = client.predict(
|
| 39 |
"atleiwarm0003", # str in 'message' Textbox component
|
|
@@ -41,18 +47,19 @@ def restart():
|
|
| 41 |
api_name="/predict"
|
| 42 |
)
|
| 43 |
print("RESTARTED")
|
| 44 |
-
|
| 45 |
except Exception as e:
|
| 46 |
print("NO INTERNET")
|
| 47 |
print(str(e))
|
| 48 |
|
| 49 |
def placeholder(dummy):
|
| 50 |
-
|
|
|
|
| 51 |
|
| 52 |
t = Thread(target=warmer)
|
| 53 |
r = Thread(target=restart)
|
| 54 |
t.start()
|
| 55 |
r.start()
|
| 56 |
|
| 57 |
-
iface = gr.Interface(fn=placeholder, inputs="text", outputs=
|
| 58 |
iface.launch()
|
|
|
|
| 32 |
print("NO INTERNET")
|
| 33 |
print(str(e))
|
| 34 |
|
| 35 |
+
counter = 0
|
| 36 |
def restart():
|
| 37 |
+
global counter
|
| 38 |
while True:
|
| 39 |
+
counter = 0
|
| 40 |
+
while counter <= 86400: #Restart Space every 24 hours
|
| 41 |
+
counter += 1
|
| 42 |
+
time.sleep(1)
|
| 43 |
try:
|
| 44 |
text_output,image_output = client.predict(
|
| 45 |
"atleiwarm0003", # str in 'message' Textbox component
|
|
|
|
| 47 |
api_name="/predict"
|
| 48 |
)
|
| 49 |
print("RESTARTED")
|
| 50 |
+
|
| 51 |
except Exception as e:
|
| 52 |
print("NO INTERNET")
|
| 53 |
print(str(e))
|
| 54 |
|
| 55 |
def placeholder(dummy):
|
| 56 |
+
global counter
|
| 57 |
+
return counter
|
| 58 |
|
| 59 |
t = Thread(target=warmer)
|
| 60 |
r = Thread(target=restart)
|
| 61 |
t.start()
|
| 62 |
r.start()
|
| 63 |
|
| 64 |
+
iface = gr.Interface(fn=placeholder, inputs="text", outputs=counter)
|
| 65 |
iface.launch()
|