Skip to content

Commit 298534c

Browse files
committed
only shutdown if started
1 parent 0d70594 commit 298534c

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/idom/backend/_common.py

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ async def serve_development_asgi(
3232
started: asyncio.Event | None,
3333
) -> None:
3434
"""Run a development server for starlette"""
35+
started = started or asyncio.Event()
36+
3537
server = UvicornServer(
3638
UvicornConfig(
3739
app,
@@ -42,15 +44,11 @@ async def serve_development_asgi(
4244
)
4345
)
4446

45-
coros: list[Awaitable[Any]] = [server.serve()]
46-
47-
if started:
48-
coros.append(_check_if_started(server, started))
49-
5047
try:
51-
await asyncio.gather(*coros)
48+
await asyncio.gather([server.serve(), _check_if_started(server, started)])
5249
finally:
53-
await asyncio.wait_for(server.shutdown(), timeout=3)
50+
if started.is_set():
51+
await asyncio.wait_for(server.shutdown(), timeout=3)
5452

5553

5654
async def _check_if_started(server: UvicornServer, started: asyncio.Event) -> None:

0 commit comments

Comments
 (0)