Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
flask to uwsgi threading issue
#1
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.
Reply
#2
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask_table module compatibility issue: cannot import name 'Markup' from 'flask' venkateshbalagiri 1 181 Mar-22-2024, 05:07 AM
Last Post: venkateshbalagiri
  How to set up uwsgi and nginx? Stas43 2 1,181 Apr-21-2023, 10:51 AM
Last Post: Stas43
  Python flask uwsgi nginx docker mfaridi 2 1,795 Sep-14-2022, 11:07 AM
Last Post: mfaridi
  run watchdog in flask app with uwsgi experimental 0 2,871 Apr-25-2020, 09:44 PM
Last Post: experimental
  location settings for Django Uwsgi Nginx Configuration for production sandyman 0 2,947 Sep-15-2017, 09:08 AM
Last Post: sandyman
  Django+uWsgi unable to find "application" callable rosettas 3 11,856 Aug-24-2017, 01:41 PM
Last Post: nilamo
  Problems configuring and running uWSGI easy_c0mpany80 3 11,713 Dec-06-2016, 09:52 AM
Last Post: easy_c0mpany80

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020