I'm getting strange behavior with uGreen. First of all, I'm using nginx 1.0.4 
and uWSGI 0.9.8 (uWSGI 0.9.8 (32bit) on [Sat Jun 11 08:57:38 2011]). I'll post 
my configurations further down as well, but first the problem. My tests are 
using a single nginx worker, and a single uwsgi worker with two async cores (so 
I should be able to handle two asynchronous requests at a time if I use uGreen 
properly).

def application(e, s):
    s('200 OK', [('Content-Type', 'text/html')])
    uwsgi.async_sleep(5)
    return ['Hello world']

This should be able to handle two asynchronous requests that finish at the same 
time. Instead however, the first request finishes first, and only then does the 
second request start. Which means it takes 10 seconds for the second request. 
You can see it clearly in the logs from uwsgi, both start at 09:10:10 and 
should both finish at around 09:10:15, instead the second request isn't served 
until after the first finishes, both are also served on core 1, rather than 
being mapped properly from the looks of things.


[pid: 12904|app: 0|req: 1/1] 192.168.1.2 () {48 vars in 812 bytes} [Sat Jun 11 
09:10:15 2011] GET /main/ => generated 5 bytes in 5005 msecs (HTTP/1.1 200) 1 
headers in 44 bytes (3 switches on core 1)
[pid: 12904|app: 0|req: 2/2] 192.168.1.2() {48 vars in 812 bytes} [Sat Jun 11 
09:10:20 2011] GET /main/ => generated 5 bytes in 5002 msecs (HTTP/1.1 200) 1 
headers in 44 bytes (3 switches on core 1)

Just to be extensive, I tried this example:

def application(e, s):
    s('200 OK', [('Content-Type', 'text/html')])
    for i in xrange(5):
        uwsgi.async_sleep(1)
        yield 'Yielding %s<br/>' % time.time()

Opening two tabs at the same time, and the output I see is the following. In 
tab 1:

Yielding 1307780762.4
Yielding 1307780763.4
Yielding 1307780764.4
Yielding 1307780765.4
Yielding 1307780766.41

In tab 2:

Yielding 1307780767.42
Yielding 1307780768.42
Yielding 1307780769.42
Yielding 1307780770.42
Yielding 1307780771.42

I cannot figure out what is wrong, the code is clearly sleeping, but it seems 
like the entire worker goes to sleep instead of just that core that this is 
called in. My configuration:


uwsgi:
    socket: 127.0.0.1:8081
    pythonpath: /home/djingoa/www/
    mount: /main=/home/djingoa/www/test.py
    master: true
    workers: 1
    harikari: 60
    ugreen: true
    async: 2



user dingoa users;
worker_processes 1;
events {
    worker_connections 1024;
}

http {
    include mime.types;
    send file on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    gzip on;
    server {
        listen 8080;
        server_name localhost default;
        location / {
            include uwsgi_params;
            uwsgi_param SCRIPT_NAME /main;
            uwsgi_pass 127.0.0.1:8081;
        }
    }
}
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to