Python Forum

Full Version: flask to uwsgi threading issue
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I dont know if its the right forum but ill post anyways, feel free to delete if its not.

Using Python 3.7.3, uwsgi 2.0.18, (docker container image python:3-stretch)
We have dev env where we are runing our code on flask and we change it to uwsgi when we test on production.
Im running a py script which get live-stream pcm audio from redis
Now when we run it on flask all works fine! when we run it on uwsgi threads gets stuck and die.

uwsgi settings :
[uwsgi]
http =  :5000
socket = :3031
wsgi-env-behaviour=holy
master=1
uid=1000
gid=2000
master=1
processes = 1
threads = 1
protocol = uwsgi
wsgi-file = server.py
chdir = /app/base/
callable = app
http-raw-body
single-interpreter
paste-logger = true
honour-stdin
#logto = /tmp/errlog
vacuum = true
harakiri-verbose = true
harakiri = 60
cpu-affinity =3
http-timeout = 60
optimize = 2
http-keepalive
listen=30
workers = 40
ugreen
reaper
start_response-nodelay
greenlet
logs :

HARAKIRI: -- wchan> 0
Wed Jun  5 15:55:48 2019 - HARAKIRI !!! worker 24 status !!!
Wed Jun  5 15:55:48 2019 - HARAKIRI [core 0] XX.XX.XX.XX- GET /pcm_json since 1559750087
Wed Jun  5 15:55:48 2019 - HARAKIRI !!! end of worker 24 status !!!
Wed Jun  5 15:55:48 2019 - *** HARAKIRI ON WORKER 27 (pid: 32, try: 1) ***

DAMN ! worker 10 (pid: 15) died, killed by signal 9 :( trying respawn ...
Respawned uWSGI worker 10 (new pid: 64)
whats the major differance between python and flask regarding post and get requests ?
after googlins 2 days in a row the no matter how much i have changed the settings nothing helps, i have tried all things suggested.

we are considering moving to gunicorn..
Thanks.
So, i figured what made the uwsgi workers crash :

" harakiri = 60" 
in my uwsgi.ini conf , because our workers connection is for long time ( giving livestream) i guess harakiri thought it was overload or taking to much time so after 60 sec it would crash it.

for our server - multi-connection and livestream this settings works :
[uwsgi]
http =  :5000
socket = :3031
wsgi-env-behaviour=holy
master=1
uid=1000
gid=2000
master=1
threads = 4
protocol = uwsgi
wsgi-file = machine.py
chdir = /app
callable = app
http-raw-body
single-interpreter
paste-logger = true
honour-stdin
cpu-affinity =3
http-timeout = 60
optimize = 2
http-keepalive
listen=30
workers = 80
ugreen
reaper
start_response-nodelay
greenlet
offload-threads = 10