Fix gunicorn worker crashes on macOS#2839
Merged
crivetimihai merged 2 commits intomainfrom Feb 11, 2026
Merged
Conversation
4adb8bf to
925ffd3
Compare
66813e7 to
925ffd3
Compare
kevalmahajan
previously approved these changes
Feb 11, 2026
Member
kevalmahajan
left a comment
There was a problem hiding this comment.
Tested on mac OS, works as expected.
On macOS, gunicorn's preload feature causes SIGSEGV crashes when using uvicorn workers with async libraries (SQLAlchemy, asyncio). This is due to macOS's strict fork-safety requirements. Changes: - Disable preload_app by default on macOS in both config and shell script - Users can override with GUNICORN_PRELOAD_APP=true if needed Refs: benoitc/gunicorn#2761 Closes #2837 Signed-off-by: Madhav Kandukuri <madhav165@gmail.com>
925ffd3 to
0012ba8
Compare
crivetimihai
approved these changes
Feb 11, 2026
ja8zyjits
pushed a commit
that referenced
this pull request
Feb 13, 2026
* fix: disable preload on macOS to prevent worker SIGSEGV crashes On macOS, gunicorn's preload feature causes SIGSEGV crashes when using uvicorn workers with async libraries (SQLAlchemy, asyncio). This is due to macOS's strict fork-safety requirements. Changes: - Disable preload_app by default on macOS in both config and shell script - Users can override with GUNICORN_PRELOAD_APP=true if needed Refs: benoitc/gunicorn#2761 Closes #2837 Signed-off-by: Madhav Kandukuri <madhav165@gmail.com> * lint Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Madhav Kandukuri <madhav165@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
* fix: disable preload on macOS to prevent worker SIGSEGV crashes On macOS, gunicorn's preload feature causes SIGSEGV crashes when using uvicorn workers with async libraries (SQLAlchemy, asyncio). This is due to macOS's strict fork-safety requirements. Changes: - Disable preload_app by default on macOS in both config and shell script - Users can override with GUNICORN_PRELOAD_APP=true if needed Refs: benoitc/gunicorn#2761 Closes IBM#2837 Signed-off-by: Madhav Kandukuri <madhav165@gmail.com> * lint Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Madhav Kandukuri <madhav165@gmail.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🐛 Bug-fix PR
Fixes #2837
Summary
Disables gunicorn's
--preloadoption by default on macOS to prevent worker processes from crashing with SIGSEGV errors.Problem
On macOS, running
make servecauses gunicorn workers to crash immediately after spawning:This happens because macOS has strict fork-safety requirements. When
--preloadis used, the application code (including SQLAlchemy and asyncio) is loaded in the master process before workers are forked. The forked workers inherit invalid state and crash when trying to use these libraries.Changes
gunicorn.config.py
platformmodulepreload_app = platform.system() != "Darwin"to disable preload on macOSworker_class = "uvicorn.workers.UvicornWorker"configurationrun-gunicorn.sh
uname -scheckGUNICORN_PRELOAD_APP=falseby default on macOSGUNICORN_PRELOAD_APP=truedefault on Linux and other platformsTesting
make serve- workers spawn and stay running--preloadflag is not passed on macOSPreload App: falseshown in startup logs on macOSBackwards Compatibility
GUNICORN_PRELOAD_APP=trueif they need preload on macOS🧪 Verification
make lintmake test📐 MCP Compliance (if relevant)
✅ Checklist
make black isort pre-commit)