1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 19:26:48 +00:00

fix(wsgi): only install SIGCHLD handler from the main thread

runserver imports the WSGI application from a worker thread, where
signal.signal() raises ValueError and the dev server fails to start.
Gunicorn imports it from the worker's main thread, so production
keeps reaping child processes as before.
This commit is contained in:
catborise 2026-10-02 12:04:41 +03:00
parent a3a6961155
commit 0f362f697c

View file

@ -8,7 +8,12 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import signal
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
import threading
# Reap child processes to avoid zombies. Signal handlers can only be set from
# the main thread; runserver imports this module from a worker thread.
if threading.current_thread() is threading.main_thread():
signal.signal(signal.SIGCHLD, signal.SIG_IGN)
import os