question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Huge number of workers fired up when I tried to run the app using PyInstaller generated byte code

See original GitHub issue

Checklist

  • [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:

  1. Install PyInstaller and run “pyinstaller --onefile -w test.spec”. A byte code executable ‘test’ is generated in dist/ directory.
  2. Run the executable as ‘./test’. testspec.txt testpy.txt Screen Shot 2021-01-19 at 5 58 39 PM

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. Screen Shot 2021-01-19 at 5 45 52 PM

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:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
selimbcommented, Feb 1, 2021

@saiprasadjnv Can you try adding multiprocessing.freeze_support() to the if __name__ == "__main__": block?

0reactions
selimbcommented, Feb 1, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - .app made using PyInstaller closes straight away?
app using PyInstaller. The actual code runs fine through IDLE, but everytime I try and run the newly converted .app, it closes straight...
Read more >
Using Spec Files - PyInstaller
Its code is the first to execute at run-time. For certain uses you may edit the contents of myscript.spec (described under Using Spec...
Read more >
Changelog — Python 3.11.1 documentation
gh-97612: Fix a shell code injection vulnerability in the get-remote-certificate.py example script. The script no longer uses a shell to run openssl commands....
Read more >
0xdf hacks stuff | CTF solutions, malware analysis, home lab ...
NET application in many different ways. I'll start by uploading a SHTML file that allows me to read the configuration file for the...
Read more >
Problems with Pyinstaller & and Common Fixes - YouTube
uite error prone, and many people have run into alot of constant errors and problems while using Pyinstaller. This Video was created for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found