2

im Using Python 3.7.3, uwsgi 2.0.18, (docker container image python:3-stretch)

We have development environment where we are running our code on flask and we change it to uwsgi when we test it on production. Im running a py script which get live-stream pcm audio from redis (another container)

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 difference between flask and uwsgi regarding post and get requests ?

After googlins 2 days in a row no matter how much i have changed the settings nothing helps, i have tried all things suggested.

we are considering moving to gunicorn.. Thanks.

EDIT:

this is the code sendind request :

conn = http.client.HTTPConnection(server, port)
 headers = { "ID": ID, "debugLevel": 1, "Multipart": 1, "Audio": 1, "Accept": "application/json" } conn.request("GET", "/pcm", "", headers)
 ret = conn.getresponse() 

this is another error i see in cli

Unhandled exception in thread started by <function get_pcm>
5
  • Could you include an example request?
    – oxr463
    Jun 5 '19 at 16:37
  • You should look at where in your code do your threads get stuck? Jun 5 '19 at 17:43
  • @LucasRamage the request in the code looks like this : conn = http.client.HTTPConnection(server, port) headers = { "ID": ID, "debugLevel": 1, "Multipart": 1, "Audio": 1, "Accept": "application/json" } conn.request("GET", "/pcm", "", headers) ret = conn.getresponse() Jun 6 '19 at 5:35
  • @MichaelHampton yes but in flask it does not happens. only in uwsgi thats why i want to know the diff between flask and uwsgi. if you have a suggestion on how to see where it is stuck please let me know (im new to python) Jun 6 '19 at 5:38
  • @BatchenRegev, I meant the actual request/response, like in postman or a proxy tool.
    – oxr463
    Jun 6 '19 at 12:39
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.