Riccardo Magliocchetti | 24 Nov 23:51 2015

uwsgi sprint december 1st

Hello everyone,

on December 1st from 5.30 PM to 9.30 PM UTC we plan to do a small code sprint. 
Ever wanted to contribute but for some reason didn't? We have quite a few issues 
that are sitting in github waiting for you. If writing is your skill look for 
documentation labelled issue, if you want to start hacking in c or python look 
for easy patch marked issues, if you feel more confident looks for bugs or 
feature request labels. The more bug we are able to squash the better :)

We are going to coordinate in #uwsgi irc channel on the freenode network.

If you happen to live near Torino, Italy we are going to have a small meetup so 
write me off list for more details.

Looking forward to see some new contributors!

Relevant repositories:



Riccardo Magliocchetti
 <at> rmistaken

Marco De Paoli | 18 Nov 15:43 2015

uwsgi (or postgres?) crisis

Today we have got a little crisis
But I don't know why it started ... and why it ended!

my uwsgi.log was full of:

"SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request"

"IOError: write error"

"uwsgi_response_writev_headers_and_body_do(): Broken pipe [core/writer.c line 296]"

"DAMN ! worker 3 (pid: 21418) died, killed by signal 9 :( trying respawn ..."

I restarted uwsgi service with no result: again, uwsgi.log full of the same messages!

On the browser I got the nginx message "Bad Gateway"

The uwsgi host hadn't any CPU or memory crisis

So I crossed my fingers and I tried a full restart
And... all fine!

So far so good, ... but why?!?

Here's another important notice:

At about the same time the crisis started, I got a NetEye warning on postgres

Notification Type: PROBLEM
Additional Info: POSTGRES_LOCKS WARNING: DB postgres (host: total locks: 1397

And about when the crisis ended (after I restarted the uwsgi host), I got a NetEye notice

Notification Type: RECOVERY
Additional Info: POSTGRES_LOCKS OK: DB postgres (host: total=571

But which is the cause and which the effect?

Last information:
Just on the same period of time I noticed an incredible list of page accesses from the same IP
I guess it is a script to automate some user actions on the site

Ok, then we have 3 ingredients:
1) uwsgi: Broken pipe, worker restart
2) postgres lock warnings
3) some script to access my django pages

My plan is as follows:
a) ask on uwsgi list for any idea ... and here I am :-)
b) schedule a detailed query on postgres to determine the exact objects locked (the actual NetEye monitor gives me just a "count")
c) activate some sort of DOS filter on nginx to stop undesired HTTP "scripting" (http://nginx.org/en/docs/http/ngx_http_limit_req_module.html)

But the step (a) is the step, well, (A)!
I admit I dream of something as:
"Hi, you should just change the parameter 'cabina-telefonica-per-super-uwsgi' to 1 and all will be ok"

So here I am: does exist any "super-uwsgi" parameter which I am not aware of? :-)

Otherwise what you think?
Have you any hint / link /advice or other?

Thank you so much for your attention!

P.S. I had another similar crisis some months ago
Same uwsgi messages and same postgres NetEye notice
I tried a uwsgi restart but with no effect
Everything fine after about 15 minutes without the need of a full host restart

uWSGI mailing list
Riccardo Magliocchetti | 16 Nov 09:46 2015

Re: nginx connection reset when reloading uwsgi


Il 16/11/2015 02:43, 陈泽佳 ha scritto:
> I'm using uwsgi as my python web app server, and nginx as a proxy.
> According to the uwsgi documents, the reload should be graceful. However, when I
> reload the uwsgi, some nginx errors (connection reset by peer) occur.

graceful reloading is a bit more complex than your configuration, see [1] as you 
are not using a subscription server your reload would not be graceful at all.


> I use uwsgi The problem also occurs when I use the latest version of
> uwsgi.

Please use the latest stable version.



Riccardo Magliocchetti
 <at> rmistaken

uWSGI mailing list
uWSGI <at> lists.unbit.it
est | 12 Nov 09:14 2015

Any tips on uwsgi packaging for as easy as Go program??

hello list,

I have this django+uwsgi project need to ship to a client. I wanna make sure it's dead simple as possible, something like copy package, run package and viola would be awesome.

So I looked into this, setuptools installs package to system CPython''s site-packages, wheel looks fine but you gotta extra deps to install forehand.

So is there a simpler way to use uwsgi based django project? 

 - need uwsgi emperor placed in rc.local 
 - need external access commands like kill -HUP uwsgi
 - need external access to django manage.py commands

Is it possible? Only options is to build deb or rpm packages?
uWSGI mailing list
Kaiwen Xu | 11 Nov 08:45 2015

rbthreads plugin questions


I have some questions about using rbthreads plugins to enable threading for Ruby applications (with rack).

1. How do you consider the plugin to be production ready? Or using threads with Ruby in general? Basically
how will it affect the stability of Ruby application?
2. Why isn’t rbthreads directly integrated with rack plugin? Is it mainly because of rbthreads only
works with Ruby 1.9+?

uWSGI mailing list
uWSGI <at> lists.unbit.it
Tomasz Czyż | 8 Nov 20:59 2015

PHP routing, serve files from two directories


I would like to serve two applications with uwsgi:
- application A under /appA (and all subfolders) 
- application B under / (and all subfolders except /appA)

My setup:
I use Debian 8 with uwsgi 2.0.7-debian
arch: x86_64
uwsgi is at the front, serving app and static files

My config file is:


http-socket     =

# maximum processes num.
processes       =  10
# minimum processes num.
cheaper         =  1

chdir           =  /www

# this two routes does not work (appA is executed with this URL which gives 404)
# I have tried setscriptfile as well
route = ^/app-B/index.php setfile:/www/app-B/app-B/index.php
route = ^/app-B/ setfile:/www/app-B/app-B/index.php

# this to routes are just to make nice urls:
# * / -> serves /index.php
# * /dir -> serves /dir/index.php
route-if = isdir:/www/app-A${PATH_INFO} rewrite:${PATH_INFO}/index.php
route-if-not = isfile:/www/app-A${PATH_INFO} rewrite:/index.php

php-set         =  open_basedir=/www/app-A/:/www/tmp/:/www/app-B
php-set         =  include_path=/www/app-A/:/www/app-B
php-set         =  date.timezone=UTC
php-set         =  upload_max_filesize = 100M
php-set         =  post_max_size = 100M
php-set         =  upload_tmp_dir=/www/tmp/
php-set         =  display_errors=On
php-set         =  display_startup_errors=On
php-set         =  error_reporting=E_ALL&~E_NOTICE
php-set         =  error_log = /tmp/php.error.log

php-docroot     =  /www/app-A/
#php-docroot     =  /www/app-B/   -- this is probably not allowed, break stuff if enabled
php-index       =  index.php
php-allowed-ext =  .php
php-allowed-ext =  .inc

# serving static files with / (app-A) and /app-B (app-B) works perfectly
# the problem is only with php files
static-skip-ext = .php
static-skip-ext = .inc

# end of the config

Do you have any ideas how I can set up routing (or other options) to serve /app-B from a different directory than app-A?

---- showconfig
# uwsgi --show-config uwsgi.ini 
[uWSGI] getting INI configuration from uwsgi.ini
[uwsgi-static] added check for /www/app-A/
[uwsgi-static] added check for /www/app-B/

;uWSGI instance configuration
show-config = true
master = true
plugin = http,0:php,router_uwsgi,router_rewrite
http-socket =
processes = 10
cheaper = 1
chdir = /www
route = ^/appB/index.php setfile:/www/app-B/app-B/index.php
route = ^/appB/ setfile:/www/app-B/app-B/index.php
route-if = isdir:/www/app-A${PATH_INFO} rewrite:${PATH_INFO}/index.php
route-if-not = isfile:/www/app-A${PATH_INFO} rewrite:/index.php
php-set = open_basedir=/www/app-A/:/www/tmp/:/www/app-B
php-set = include_path=/www/app-A/:/www/app-B
php-set = date.timezone=UTC
php-set = upload_max_filesize = 100M
php-set = post_max_size = 100M
php-set = upload_tmp_dir=/www/tmp/
php-set = display_errors=On
php-set = display_startup_errors=On
php-set = error_reporting=E_ALL&~E_NOTICE
php-set = error_log = /tmp/php.error.log
php-docroot = /www/app-A/
php-index = index.php
php-allowed-ext = .php
php-allowed-ext = .inc
check-static = /www/app-A/
check-static = /www/app-B/
static-skip-ext = .php
static-skip-ext = .inc
;end of configuration

*** Starting uWSGI 2.0.7-debian (64bit) on [Sun Nov  8 19:52:23 2015] ***
compiled with version: 4.9.1 on 25 October 2014 19:17:54
os: Linux-3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u5 (2015-10-09)
nodename: da0e8addb646
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 1
current working directory: /
detected binary path: /usr/bin/uwsgi-core
*** dumping internal routing table ***
[rule: 0] subject: path_info regexp: ^/app-B/index.php action: setfile:/www/app-B/app-B/index.php
[rule: 1] subject: path_info regexp: ^/app-B/ action: setfile:/www/app-B/app-B/index.php
[rule: 2] subject: /www/app-A${PATH_INFO} func: isdir action: rewrite:${PATH_INFO}/index.php
[rule: 3] subject: /www/app-A${PATH_INFO} func: !isfile action: rewrite:/index.php
*** end of the internal routing table ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your processes number limit is 1048576
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
building mime-types dictionary from file /etc/mime.types...547 entry found
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address fd 3
uwsgi socket 1 bound to TCP address fd 4
PHP 5.6.2-1 initialized
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 1111616 bytes (1085 KB) for 10 cores
*** Operational MODE: preforking ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 14)
spawned uWSGI worker 1 (pid: 16, cores: 1)

uWSGI mailing list
Roberto De Ioris | 3 Nov 10:19 2015

An aiohttp example (special branch)

Hi, i have worked a bit on allowing development of custom uWSGI workers
(using higher level languages).

The following is an example of integrating python aiohttp in uWSGI:


You need a special 2.0 branch to use it (but once i get positive report i
can merge to 2.0 easily)

This kind of use is obviously out of the WSGI standard, so if you care it,
simply do not use it :)


Roberto De Ioris
Brian Swanson | 31 Oct 05:50 2015

Getting unexpected truncation behavior from rsyslog logger plugin


Messages sent to rsyslog get truncated to ~2K bytes.  Only the messages sent by uWSGI are being truncated. 
Messages sent to the same rsyslog socket by other applications, such as the logger command, are not truncated.


	• Fedora Workstation 22
	• uWSGI installed from dnf
	• uWSGI rsyslog logger pluggin installed from dnf
	• rsyslogd installed using dnf

Relevant rsyslogd.conf settings:

	$MaxMessageSize 300000  <— I put this at the top of the file, and based on the fact the “logger”
command is able to send huge messages I can only assume this is working as expected.
        $ModLoad imuxsock
        $SystemLogSocketName /run/systemd/journal/syslog

Relevant myuwsgi.conf settings:

	plugins-dir = /usr/lib64/uwsgi
	plugin = python
	plugin = rsyslog
	rsyslog-packet-size = 300000
	logger = rsyslog:/run/systemd/journal/syslog,uwsgi_mgmt

Any thoughts or advice is greatly appreciated.


uWSGI mailing list
uWSGI <at> lists.unbit.it
Daniel Kraus | 29 Oct 05:14 2015

python uwsgi module stub


I just uploaded a python uwsgi module stub to pypi and thought
some here maybe interested in that as well.

It was always a little bit annoying if you
`import uwsgi` in your code and the editor hightlights it as
error and doesn't have autocompletion etc.

Find the code here: https://github.com/dakra/uwsgi-stub
or just install it with `pip install uwsgi-stub`

David Montgomery | 23 Oct 23:15 2015

<at> rbtimer(120,target='workers') kinda works


I am using the gevent loop with python bottle.

So every 120 seconds I load data from redis into a python hash.  For a sanity check I save the data as a json string every 120 and can verify that the data is updated due to the timer from the saved data I see on disk.

However, the worker has to use the updated hash to select items that might have been updated from the data that was supposed to be updated from the reloaded data.  However it is not.  For me to get updated data that works I have to do a touch reload which defeats the purpose.  Below is my logic.  So how do I resolve?


from uwsgidecorators import *
<at> rbtimer(120,target='workers')
 def load_redis(signum):
    updated_hash = redis.get('data')
   with open('/tmp/meta_post.json', 'w') as outfile:
            json.dump(updated_hash, outfile, indent=4, sort_keys=True)  <-THIS WORKS

def foo(updated_hash){
    do stuff

<at> get('/hash/')
def hash():

      json_data = foo(updated_hash) <- THIS USES OLD DATA
      return json_data
uWSGI mailing list
Bo Lorentsen | 23 Oct 21:49 2015

documentation of uwsgi.h file

Hi ...

I am quite new to uwsgi and this list, so I am sorry if this has been 
asked before.

I like to make a C++ plugin, using the uwsgi plugin interface. Currently 
a maintain my own scgi server and dispatcher, but I really like to us 
all the nice features build into uwsgi, but from my (mutli-threaded C++) 
plugin (jsonrpc + restful).

So, after discovering the "uwsgi --build-plugin ." interface, I finally 
found the uwsgi.h file, but I can't seem to find any documentation on 
the content of this header file, have I not been looking hard enough or 
is it not been written ... yet ?

I guess that the python api doc, is a good inspiration, and I could also 
just read the source or make inspired guesses, but if there is some doc 
on this file, I will love to know where to find it.