3

could you be so kind and help me with the problem?

I'm running Apache 2.2.22 with mod_wsgi

I configured WSGI properly to work on multiple threads and am using Python I need to handle parallel requests from same browser, but the only parallel request wsgi can serve are the ones coming from different browsers (or 1 browser tab + 1 tab in incognito).

I tried both embedded and daemon.

Apache configuration:

WSGIDaemonProcess appname processes=5 threads=25 display-name=%{GROUP}
WSGIProcessGroup appname 

WSGIScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    AddHandler wsgi-script .py
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    #Require all granted
</Directory>

I put wsgi.py in /usr/lib/cgi-bin directory with 755 mod

the content of wsgi.py:

import os, sys
import time
from datetime import datetime

def application(environ, start_response):

    sys.stderr.write("before wait time = %s\n" % str(datetime.now()))
    sys.stderr.write("client= %s\n" % environ['REMOTE_ADDR'])
    sys.stderr.write("waiting\n")
    print >> sys.stderr, 'mod_wsgi.process_group = %s' % repr(environ['mod_wsgi.process_group'])
    time.sleep(10)
    sys.stderr.write("wait finished time = %s\n" % str(datetime.now()))
    status = '200 OK'
    output = 'Hello World!'

    response_headers = [('Content-type', 'text/plain'),
                    ('Content-Length', str(len(output)))]
    start_response(status, response_headers)

    return [output]

When requesting http://my.ip/cgi-bin/wsgi.py I'm getting all fine, but when I run it parallel in 2 tabs of single browser, the second tab is waiting for the first to finish ... logs:

[Tue Sep 02 18:25:06 2014] [error] before wait time = 2014-09-02 18:25:06.365133
[Tue Sep 02 18:25:06 2014] [error] client= 192.168.113.35
[Tue Sep 02 18:25:06 2014] [error] waiting
[Tue Sep 02 18:25:06 2014] [error] mod_wsgi.process_group = 'appname'
[Tue Sep 02 18:25:16 2014] [error] wait finished time = 2014-09-02 18:25:16.371944
[Tue Sep 02 18:25:16 2014] [error] before wait time = 2014-09-02 18:25:16.390348
[Tue Sep 02 18:25:16 2014] [error] client= 192.168.113.35
[Tue Sep 02 18:25:16 2014] [error] waiting
[Tue Sep 02 18:25:16 2014] [error] mod_wsgi.process_group = 'appname'
[Tue Sep 02 18:25:26 2014] [error] wait finished time = 2014-09-02 18:25:26.400464

1 Answer 1

1

I would not be surprised if this has to do with the browser recycling open connections to the server to send subsequent requests. If it opens a new connection for a request sent from an incognito tab, that would allow a separate thread on the server to handle it; that this works properly shows that your WSGI setup is basically ok.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.