Spaces:
Sleeping
Sleeping
Meet Patel
commited on
Commit
Β·
66fc7d8
1
Parent(s):
35bb43f
Fix: Start ping task when Gradio app loads to avoid event loop issues
Browse files
app.py
CHANGED
@@ -46,8 +46,17 @@ async def start_periodic_ping(interval_minutes: int = 10) -> None:
|
|
46 |
await ping_mcp_server()
|
47 |
await asyncio.sleep(interval_minutes * 60)
|
48 |
|
49 |
-
#
|
50 |
-
ping_task =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
|
53 |
async def load_concept_graph(concept_id: str = None) -> Tuple[Optional[plt.Figure], Dict, List]:
|
@@ -316,6 +325,9 @@ def sync_load_concept_graph(concept_id):
|
|
316 |
|
317 |
# Create Gradio interface
|
318 |
with gr.Blocks(title="TutorX Educational AI", theme=gr.themes.Soft()) as demo:
|
|
|
|
|
|
|
319 |
gr.Markdown("# π TutorX Educational AI Platform")
|
320 |
gr.Markdown("""
|
321 |
An adaptive, multi-modal, and collaborative AI tutoring platform built with MCP.
|
|
|
46 |
await ping_mcp_server()
|
47 |
await asyncio.sleep(interval_minutes * 60)
|
48 |
|
49 |
+
# Store the ping task reference
|
50 |
+
ping_task = None
|
51 |
+
|
52 |
+
def start_ping_task():
|
53 |
+
"""Start the ping task when the Gradio app launches"""
|
54 |
+
global ping_task
|
55 |
+
if ping_task is None:
|
56 |
+
loop = asyncio.get_event_loop()
|
57 |
+
ping_task = loop.create_task(start_periodic_ping())
|
58 |
+
print("Started periodic ping task")
|
59 |
+
|
60 |
|
61 |
|
62 |
async def load_concept_graph(concept_id: str = None) -> Tuple[Optional[plt.Figure], Dict, List]:
|
|
|
325 |
|
326 |
# Create Gradio interface
|
327 |
with gr.Blocks(title="TutorX Educational AI", theme=gr.themes.Soft()) as demo:
|
328 |
+
# Start the ping task when the app loads
|
329 |
+
demo.load(start_ping_task)
|
330 |
+
|
331 |
gr.Markdown("# π TutorX Educational AI Platform")
|
332 |
gr.Markdown("""
|
333 |
An adaptive, multi-modal, and collaborative AI tutoring platform built with MCP.
|