Skip to content

Commit f8e8d18

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 31639ec commit f8e8d18

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
@@ -84,7 +84,11 @@ def _signal_handler(*_: Any) -> None: # noqa: N803
8484
if lifespan_task.done():
8585
exception = lifespan_task.exception()
8686
if exception is not None:
87-
raise exception
87+
await config.log.exception(
88+
"Error initializing ASGI app",
89+
exc_info=(type(exception), exception, exception .__traceback__)
90+
)
91+
exit(1)
8892

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

0 commit comments

Comments
 (0)