Repository navigation
pyuwsgi + enable-threads + python3.12: workers do not recover after a reload #2659
Copy link
Copy link
Closed
Description
reproduction:
python3.12 -m venv venv
. venv/bin/activate
pip install pyuwsgi
bash t.sh# wsgi.py
def application(environ, start_response):
print('.', end='', flush=True)
status = '200 OK'
output = b'!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]# t.sh
UWSGI_MASTER=true \
UWSGI_BINARY_PATH=$PWD/venv/bin/python3 \
UWSGI_VIRTUALENV=$PWD/venv \
UWSGI_WORKERS=2 \
UWSGI_ENABLE_THREADS=true \
UWSGI_MAX_REQUESTS=5 \
UWSGI_HTTP_SOCKET=localhost:9001 \
UWSGI_WSGI_FILE=wsgi.py \
UWSGI_DISABLE_LOGGING=1 \
venv/bin/uwsgi# some other tab / window
yes | head -300 | xargs --replace curl localhost:9001/health-check/; echooutput:
$ bash t.sh
*** Starting uWSGI 2.0.26 (64bit) on [Mon Aug 12 16:57:55 2024] ***
compiled with version: Apple LLVM 15.0.0 (clang-1500.3.9.4) on 12 August 2024 17:24:49
os: Darwin-23.5.0 Darwin Kernel Version 23.5.0: Wed May 1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000
nodename: FJJ4YYCWYX.attlocal.net
machine: arm64
clock source: unix
pcre jit disabled
detected number of CPU cores: 10
current working directory: /private/tmp/y
detected binary path: /tmp/y/venv/bin/python3
your processes number limit is 5333
your memory page size is 16384 bytes
detected max file descriptor number: 2560
lock engine: OSX spinlocks
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address localhost:9001 fd 3
Python version: 3.12.2 (main, Feb 6 2024, 20:19:44) [Clang 15.0.0 (clang-1500.1.0.2.5)]
--- Python VM already initialized ---
Python main interpreter initialized at 0x10154c4f0
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 218688 bytes (213 KB) for 2 cores
*** Operational MODE: preforking ***
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x10154c4f0 pid: 63841 (default app)
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 63841)
spawned uWSGI worker 1 (pid: 63842, cores: 1)
spawned uWSGI worker 2 (pid: 63843, cores: 1)
................................................................................................................................................................................................................................................................................................................................................................................................................................................The work of process 63843 is done. Seeya!
....The work of process 63842 is done. Seeya!
worker 2 killed successfully (pid: 63843)
Respawned uWSGI worker 2 (new pid: 64286)
worker 1 killed successfully (pid: 63842)
Respawned uWSGI worker 1 (new pid: 64287)(and then no additional output) -- the uwsgi processes also become relatively unkillable (not responding to ^C / ^\, SIGTERM etc.)
the other terminal output:
$ yes | head -300 | xargs --replace curl localhost:9001/health-check/; echo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$ yes | head -300 | xargs --replace curl localhost:9001/health-check/; echo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!this seems to not be an issue with python 3.11 or without pyuwsgi
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
asottile-sentry commentedon Aug 13, 2024
cc @methane since you seem to have been poking around in
--enable-threadsand termination recently and maybe have an idea what's going onmethane commentedon Aug 13, 2024
Try #2654
asottile commentedon Aug 14, 2024
tried that patch out but unfortunately it doesn't seem to fix it -- still getting hangs unfortunately
asottile commentedon Aug 14, 2024
if it's helpful -- an strace of the child processes while stuck shows:
the parent process:
will see if I can figure out more
asottile commentedon Aug 14, 2024
ah this is definitely more useful info -- here's the stack of the stuck children:
(edited with debug line numbers against 3.12.4 + 2.0.26 + #2654)
methane commentedon Aug 16, 2024
Try lazy-apps.
https://uwsgi-docs.readthedocs.io/en/latest/articles/TheArtOfGracefulReloading.html#preforking-vs-lazy-apps-vs-lazy
asottile-sentry commentedon Aug 16, 2024
still an issue. I'm going to try and bisect cpython today and see if I can't find what changed and where the bug lies
asottile commentedon Aug 16, 2024
alrighty -- here's the result of bisection!
python/cpython@92d8bff
asottile commentedon Aug 16, 2024
created python/cpython#123079 with a potential fix
asottile commentedon Aug 30, 2024
btw I have a fix for this in #2660 -- if you're using
pyuwsgifrom pypi this fix is cherry-picked and available in 2.0.27a1xrmx commentedon Sep 8, 2024
Fixed in #2670