Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1416,12 +1416,12 @@ if __name__ == "__main__":
|
|
1416 |
# --- Launch Gradio App & Async Tasks ---
|
1417 |
# Gradio's launch method handles the event loop integration when run directly.
|
1418 |
# It will run the asyncio tasks alongside the FastAPI/Uvicorn server.
|
1419 |
-
app.queue() # Enable queue for handling multiple requests/long-running tasks
|
1420 |
-
app.launch(
|
1421 |
# share=True, # Enable for public access (use with caution)
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
# Let Gradio manage the asyncio loop
|
1426 |
# asyncio_task=main_async_tasks() # This might conflict with launch's loop management
|
1427 |
)
|
@@ -1437,9 +1437,9 @@ if __name__ == "__main__":
|
|
1437 |
# If WS/broadcast doesn't work, we may need to manually manage the loop/threading.
|
1438 |
|
1439 |
# A common pattern if launch() blocks and doesn't run background async tasks:
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
|
1444 |
logger.info("Gradio app launched. Webhook server running in background thread.")
|
1445 |
# The asyncio tasks (WebSocket, broadcast) should be running via Gradio's event loop.
|
|
|
1416 |
# --- Launch Gradio App & Async Tasks ---
|
1417 |
# Gradio's launch method handles the event loop integration when run directly.
|
1418 |
# It will run the asyncio tasks alongside the FastAPI/Uvicorn server.
|
1419 |
+
# app.queue() # Enable queue for handling multiple requests/long-running tasks
|
1420 |
+
# app.launch(
|
1421 |
# share=True, # Enable for public access (use with caution)
|
1422 |
+
# server_name="0.0.0.0", # Bind to all interfaces for accessibility
|
1423 |
+
# server_port=7860, # Default Gradio port
|
1424 |
+
# favicon_path="[https://huggingface.co/front/assets/huggingface_logo-noborder.svg](https://huggingface.co/front/assets/huggingface_logo-noborder.svg)",
|
1425 |
# Let Gradio manage the asyncio loop
|
1426 |
# asyncio_task=main_async_tasks() # This might conflict with launch's loop management
|
1427 |
)
|
|
|
1437 |
# If WS/broadcast doesn't work, we may need to manually manage the loop/threading.
|
1438 |
|
1439 |
# A common pattern if launch() blocks and doesn't run background async tasks:
|
1440 |
+
asyncio_thread = threading.Thread(target=lambda: asyncio.run(main_async_tasks()), daemon=True)
|
1441 |
+
asyncio_thread.start()
|
1442 |
+
app.launch(...)
|
1443 |
|
1444 |
logger.info("Gradio app launched. Webhook server running in background thread.")
|
1445 |
# The asyncio tasks (WebSocket, broadcast) should be running via Gradio's event loop.
|