Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Instantiate the background scheduler only on Spaces
Browse files
app.py
CHANGED
@@ -1,3 +1,5 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
from apscheduler.schedulers.background import BackgroundScheduler
|
@@ -567,7 +569,8 @@ with gr.Blocks(css=custom_css) as demo:
|
|
567 |
|
568 |
|
569 |
if __name__ == "__main__":
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
573 |
demo.queue(default_concurrency_limit=40).launch()
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
import gradio as gr
|
4 |
import pandas as pd
|
5 |
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
569 |
|
570 |
|
571 |
if __name__ == "__main__":
|
572 |
+
if os.getenv("SPACE_ID"):
|
573 |
+
scheduler = BackgroundScheduler()
|
574 |
+
scheduler.add_job(restart_space, "interval", seconds=1800)
|
575 |
+
scheduler.start()
|
576 |
demo.queue(default_concurrency_limit=40).launch()
|