unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.45k stars 691 forks source link

Emperor throttling logic confuses micro- and milliseconds #1554

Open jeremy-hiatt opened 7 years ago

jeremy-hiatt commented 7 years ago

According to the uWSGI documentation the emperor-throttle option is specified in milliseconds. However the value to which it gets set is passed directly to usleep, which expects a value in microseconds!

Passing the desired value in microseconds causes problems with the blacklisting logic, as the throttle is assumed to be in millis and is multiplied by 1000. Thus if you've set the throttle level to 1 second (i.e. emperor-throttle = 1000000), your bad-behaving vassal won't be restarted until 1000 seconds later! Note that setting emperor-max-throttle does not prevent this from happening. One available workaround is to simply disable blacklisting altogether with the emperor-no-blacklist flag/option.

xrmx commented 7 years ago

Good catch! I think that adding a * 1000 to to both the usleep should do the trick. Care to open a PR?