Skip to content
Discussion options

You must be logged in to vote

Hi @Pibben,

With reload=True, uvicorn starts the server worker with the "spawn" method, and this child process re-runs your main script as __mp_main__ while it is still bootstrapping. Because of the if __name__ in {"__main__", "__mp_main__"}: guard, Model() runs there too, and Manager() tries to start yet another process before the worker has finished starting up. That's exactly what Python complains about. (You can also see "Creating manager" printed twice: once in the reloader process, which only watches your files, and once in the worker.)

The __mp_main__ part of the guard is only meant for ui.run, which returns immediately in child processes. Expensive side effects like starting proce…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Pibben
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants