-
-
Notifications
You must be signed in to change notification settings - Fork 729
Importing nicegui
affects mp.set_start_method
, throws context has already been set
#3644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I currently have not the time to dig deeper but it seems to be related to the auto-reloading mechanism of uvicorn. I could reproduce the same behaviour without NiceGUI: import multiprocessing as mp
import uvicorn
mp.set_start_method("spawn")
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8000, reload=True) If you set |
We don't think this is an issue with NiceGUI. |
Thanks for the feedback! The underlying issue is importing either Note that the error above happens before any code is actually "run" -- I am not calling For us, we simply worked around it by deferring the import of any Does this make sense? |
Also note that the above still fails for It does not fail for
|
If I import So this seems like it would indicate an issue somewhere in |
Sure. I can reproduce it with NiceGUI. But as said, it can be also be reproduced with uvicorn alone. So the underlying problem is "upstream". Maybe there is a workaround we can implement in NiceGUI, but I doubt that.
At first glance it looks that way. But it's important to understand the full startup process: With |
@rodja FYI it's no long reproducible upstream in uvicorn:
|
Once #4613 is merged this will work with:
|
Description
Using
nicegui == 1.4.34
, CPython 3.10.12, on Ubuntu 22.04.The following works fine:
$ python -c 'import multiprocessing as mp; mp.set_start_method("spawn")'
The following, however, fails:
The text was updated successfully, but these errors were encountered: