IDEA: python has atexit() but nothing onstartup(). Dotnet has...

@mistersql

IDEA: python has atexit() but nothing onstartup(). Dotnet has PreApplicationStartMethod() and other events early in the process/app/thread's life cycle.

Maybe if I wrote an app that hosted a single process, like a gunicorn for CLI commands. And then it could have middleware and events to hook into.

Self-replies

I just checked... adding some code to run first by letting it run at import doesn't mean it will predictably run 1st. If you add interesting code to init and then that code import anything else, those import run 1st.