Repository: gradio-app/gradio

Issue:
Warn enable_queue in reload mode
**Is your feature request related to a problem? Please describe.**  
Warn the user when enable_queue is true in the reload mode(gradio app.py)

**Additional context**  
Since we launch the app with uvicorn in the reload mode, only fastapi app is run. We could make workarounds like triggering an endpoint to the start queueing, however I don't think it is necessary.


Discussion:

Resolving patch:
diff --git a/gradio/blocks.py b/gradio/blocks.py
--- a/gradio/blocks.py
+++ b/gradio/blocks.py
@@ -1232,6 +1232,7 @@ def queue(
             blocks_dependencies=self.dependencies,
         )
         self.config = self.get_config_file()
+        self.app = routes.App.create_app(self)
         return self
 
     def launch(
diff --git a/gradio/routes.py b/gradio/routes.py
--- a/gradio/routes.py
+++ b/gradio/routes.py
@@ -481,6 +481,7 @@ async def join_queue(
         async def get_queue_status():
             return app.get_blocks()._queue.get_estimation()
 
+        @app.on_event("startup")
         @app.get("/startup-events")
         async def startup_events():
             if not app.startup_events_triggered:


Test patch:
diff --git a/test/test_blocks.py b/test/test_blocks.py
--- a/test/test_blocks.py
+++ b/test/test_blocks.py
@@ -16,12 +16,14 @@
 
 import mlflow
 import pytest
+import uvicorn
 import wandb
 import websockets
 from fastapi.testclient import TestClient
 
 import gradio as gr
 from gradio.exceptions import DuplicateBlockError
+from gradio.networking import Server, get_first_available_port
 from gradio.test_data.blocks_configs import XRAY_CONFIG
 from gradio.utils import assert_configs_are_equivalent_besides_ids
 
@@ -323,6 +325,39 @@ async def test_restart_after_close(self):
                     completed = True
             assert msg["output"]["data"][0] == "Victor"
 
+    @pytest.mark.asyncio
+    async def test_run_without_launching(self):
+        """Test that we can start the app and use queue without calling .launch().
+
+        This is essentially what the 'gradio' reload mode does
+        """
+
+        port = get_first_available_port(7860, 7870)
+
+        io = gr.Interface(lambda s: s, gr.Textbox(), gr.Textbox()).queue()
+
+        config = uvicorn.Config(app=io.app, port=port, log_level="warning")
+
+        server = Server(config=config)
+        server.run_in_thread()
+
+        try:
+            async with websockets.connect(f"ws://localhost:{port}/queue/join") as ws:
+                completed = False
+                while not completed:
+                    msg = json.loads(await ws.recv())
+                    if msg["msg"] == "send_data":
+                        await ws.send(json.dumps({"data": ["Victor"], "fn_index": 0}))
+                    if msg["msg"] == "send_hash":
+                        await ws.send(
+                            json.dumps({"fn_index": 0, "session_hash": "shdce"})
+                        )
+                    if msg["msg"] == "process_completed":
+                        completed = True
+                assert msg["output"]["data"][0] == "Victor"
+        finally:
+            server.close()
+
 
 class TestComponentsInBlocks:
     def test_slider_random_value_config(self):