Skip to content

Commit 79cef1c

Browse files
author
Pierre Delagrave
committed
Logging app initialization failure using config.log
On exiting due to an unhandled exception during the app initialization (lifespan), the process(es) spawned by `multiprocessing.BaseContext.Process.start()` in `_populate()` would have their stack traceback directly printed to stderr by `BaseProcess:_bootstrap`. Using the user-configurable `config.log` logger instead makes the log output more consistent.
1 parent 84d06b8 commit 79cef1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/hypercorn/asyncio/run.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ def _signal_handler(*_: Any) -> None: # noqa: N803
8585
if lifespan_task.done():
8686
exception = lifespan_task.exception()
8787
if exception is not None:
88-
raise exception
88+
await config.log.exception(
89+
"Error initializing ASGI app",
90+
exc_info=(type(exception), exception, exception .__traceback__)
91+
)
92+
exit(1)
8993

9094
if sockets is None:
9195
sockets = config.create_sockets()

0 commit comments

Comments
 (0)