File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444 run : |
4545 cd dist/fastapi_cli*/
4646 pip install -r requirements-tests.txt
47+ env :
48+ TIANGOLO_BUILD_PACKAGE : ${{ matrix.package }}
4749 - name : Run source distribution tests
4850 run : |
4951 cd dist/fastapi_cli*/
Original file line number Diff line number Diff line change @@ -4,3 +4,6 @@ pytest >=4.4.0,<8.0.0
44coverage[toml] >=6.2,<8.0
55mypy ==1.4.1
66ruff ==0.2.0
7+ # Needed explicitly by fastapi-cli-slim
8+ fastapi-slim
9+ uvicorn
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ def _run(
5151 host : str = "127.0.0.1" ,
5252 port : int = 8000 ,
5353 reload : bool = True ,
54+ workers : Union [int , None ] = None ,
5455 root_path : str = "" ,
5556 command : str ,
5657 app : Union [str , None ] = None ,
@@ -85,6 +86,7 @@ def _run(
8586 host = host ,
8687 port = port ,
8788 reload = reload ,
89+ workers = workers ,
8890 root_path = root_path ,
8991 proxy_headers = proxy_headers ,
9092 )
@@ -200,6 +202,12 @@ def run(
200202 help = "Enable auto-reload of the server when (code) files change. This is [bold]resource intensive[/bold], use it only during development."
201203 ),
202204 ] = False ,
205+ workers : Annotated [
206+ Union [int , None ],
207+ typer .Option (
208+ help = "Use multiple worker processes. Mutually exclusive with the --reload flag."
209+ ),
210+ ] = None ,
203211 root_path : Annotated [
204212 str ,
205213 typer .Option (
@@ -249,6 +257,7 @@ def run(
249257 host = host ,
250258 port = port ,
251259 reload = reload ,
260+ workers = workers ,
252261 root_path = root_path ,
253262 app = app ,
254263 command = "run" ,
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def test_dev() -> None:
2626 "host" : "127.0.0.1" ,
2727 "port" : 8000 ,
2828 "reload" : True ,
29+ "workers" : None ,
2930 "root_path" : "" ,
3031 "proxy_headers" : True ,
3132 }
@@ -67,6 +68,7 @@ def test_dev_args() -> None:
6768 "host" : "192.168.0.2" ,
6869 "port" : 8080 ,
6970 "reload" : False ,
71+ "workers" : None ,
7072 "root_path" : "/api" ,
7173 "proxy_headers" : False ,
7274 }
@@ -92,6 +94,7 @@ def test_run() -> None:
9294 "host" : "0.0.0.0" ,
9395 "port" : 8000 ,
9496 "reload" : False ,
97+ "workers" : None ,
9598 "root_path" : "" ,
9699 "proxy_headers" : True ,
97100 }
@@ -118,6 +121,8 @@ def test_run_args() -> None:
118121 "--port" ,
119122 "8080" ,
120123 "--no-reload" ,
124+ "--workers" ,
125+ "2" ,
121126 "--root-path" ,
122127 "/api" ,
123128 "--app" ,
@@ -133,6 +138,7 @@ def test_run_args() -> None:
133138 "host" : "192.168.0.2" ,
134139 "port" : 8080 ,
135140 "reload" : False ,
141+ "workers" : 2 ,
136142 "root_path" : "/api" ,
137143 "proxy_headers" : False ,
138144 }
@@ -171,6 +177,7 @@ def test_dev_help() -> None:
171177 assert "Enable auto-reload of the server when (code) files change." in result .output
172178 assert "The root path is used to tell your app" in result .output
173179 assert "The name of the variable that contains the FastAPI app" in result .output
180+ assert "Use multiple worker processes." not in result .output
174181
175182
176183def test_run_help () -> None :
@@ -191,6 +198,7 @@ def test_run_help() -> None:
191198 assert "Enable auto-reload of the server when (code) files change." in result .output
192199 assert "The root path is used to tell your app" in result .output
193200 assert "The name of the variable that contains the FastAPI app" in result .output
201+ assert "Use multiple worker processes." in result .output
194202
195203
196204def test_callback_help () -> None :
You can’t perform that action at this time.
0 commit comments