File tree 1 file changed +5
-7
lines changed
1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ async def serve_development_asgi(
32
32
started : asyncio .Event | None ,
33
33
) -> None :
34
34
"""Run a development server for starlette"""
35
+ started = started or asyncio .Event ()
36
+
35
37
server = UvicornServer (
36
38
UvicornConfig (
37
39
app ,
@@ -42,15 +44,11 @@ async def serve_development_asgi(
42
44
)
43
45
)
44
46
45
- coros : list [Awaitable [Any ]] = [server .serve ()]
46
-
47
- if started :
48
- coros .append (_check_if_started (server , started ))
49
-
50
47
try :
51
- await asyncio .gather (* coros )
48
+ await asyncio .gather ([ server . serve (), _check_if_started ( server , started )] )
52
49
finally :
53
- await asyncio .wait_for (server .shutdown (), timeout = 3 )
50
+ if started .is_set ():
51
+ await asyncio .wait_for (server .shutdown (), timeout = 3 )
54
52
55
53
56
54
async def _check_if_started (server : UvicornServer , started : asyncio .Event ) -> None :
You can’t perform that action at this time.
0 commit comments