Huge number of workers fired up when I tried to run the app using PyInstaller generated byte code
See original GitHub issueChecklist
- [Yes ] The bug is reproducible against the latest release and/or
master
. [Tested using uvicorn version 0.12.1] - [Yes] There are no similar issues or pull requests to fix it yet.
Describe the bug
We bundled our app using pyinstaller byte code. When we try to use 4 workers to run the application, a huge number of workers are fired up resulting in our server going down. When we remove the “workers = 4” parameter in the Uvicorn.run(), everything is working fine.
To reproduce
Server: RHEL Server on AWS EC2 instance
When I generated the pyinstaller byte code using the below files, everything works fine.
“test.py” and “test.spec” files used to generate the byte code executable.
Steps:
- Install PyInstaller and run “pyinstaller --onefile -w test.spec”. A byte code executable ‘test’ is generated in dist/ directory.
- Run the executable as ‘./test’. testspec.txt testpy.txt
But when we set the number of workers to 4, huge number of workers are fired up resulting in server going down. test1spec.txt test1py.txt Steps: Repeat the same procedure as above with test1.spec.
Expected behavior
Expected 4 workers to start.
Actual behavior
Huge number of workers are fired up resulting in server going down.
Debugging material
Environment
OS: RHEL Server on AWS EC2 instance Python: Python 3.6.8 Uvicorn version: uvicorn 0.12.1 with CPython 3.8.3 on Linux
- uvicorn.run(‘test:app’, host=‘0.0.0.0’, workers=4, port=7500)
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@saiprasadjnv Can you try adding multiprocessing.freeze_support() to the
if __name__ == "__main__":
block?Even though the docs suggest this is only required on Windows, and that’s true if you look at the code, pyinstaller monkeypatches that function.
Relevant issues: https://github.com/pyinstaller/pyinstaller/pull/4868 and https://github.com/pyinstaller/pyinstaller/issues/4865