fix: suppress noisy SSL handshake errors in gunicorn logs

Add SSLZeroReturnError and SSLError to gevent's NOT_ERROR list so
dropped TLS handshakes (browser preflight, plain HTTP to HTTPS port)
don't print scary tracebacks to the console.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Smittix
2026-03-02 10:39:52 +00:00
parent 0df412c014
commit 5e99d19165

View File

@@ -10,9 +10,12 @@ def post_worker_init(worker):
silences this harmless noise.
"""
try:
import ssl
from gevent import get_hub
hub = get_hub()
if SystemExit not in hub.NOT_ERROR:
hub.NOT_ERROR = hub.NOT_ERROR + (SystemExit,)
suppress = (SystemExit, ssl.SSLZeroReturnError, ssl.SSLError)
for exc in suppress:
if exc not in hub.NOT_ERROR:
hub.NOT_ERROR = hub.NOT_ERROR + (exc,)
except Exception:
pass