On 1 February 2010 16:55, Chris Curvey <[email protected]> wrote:
> I have a Django app running under mod_wsgi on Windows.  The app is a
> simple web service -- it takes a request (optionally with some JSON in
> the POST payload) and returns some JSON.  Request A is generated from
> a batch process that reads a file and makes periodic requests to the
> Django app.  Request B can be run from a browser and just returns some
> JSON.  Each request takes a few seconds to complete, so its easy to
> get overlapping requests.
>
> When running through WSGI, either request runs fine by itself.  But if
> I have the batch job running and kicking off Request A periodically,
> and I kick of Request B from a browser, the process kicking off
> Request A immediately reports a web error, saying the connection has
> been forcibly closed by the remote host.  In addition, the browser
> running Request B reports a 500 error.  In the Apache error logs, I
> see:
>
> [Mon Feb 01 00:04:42 2010] [notice] Parent: child process exited with
> status 3221225477 -- Restarting.
> [Mon Feb 01 00:04:42 2010] [notice] Apache/2.2.11 (Win32) mod_wsgi/2.6
> Python/2.6.2 configured -- resuming normal operations
> [Mon Feb 01 00:04:42 2010] [notice] Server built: Dec 10 2008 00:10:06
> [Mon Feb 01 00:04:42 2010] [notice] Parent: Created child process 944
> [Mon Feb 01 00:04:42 2010] [notice] Child 944: Child process is
> running
> [Mon Feb 01 00:04:42 2010] [notice] Child 944: Acquired the start
> mutex.
> [Mon Feb 01 00:04:42 2010] [notice] Child 944: Starting 64 worker
> threads.
> [Mon Feb 01 00:04:42 2010] [notice] Child 944: Starting thread to
> listen on port 80.
>
> If I run the Django app on it's own (python manage.py runserver
> "192.168.0.32:80"), the requests complete properly.  They seem to be
> single-threaded (and slow, for that reason), but they work.
>
> Versions:
> python: 2.6.2
> mod_wsgi:  mod_wsgi-win32-ap22py26-2.6.so (I also tried with mod_wsgi-
> win32-ap22py26-3.0.so and got the same result)
> Django: 1.1
> Windows:  Windows Server 2008, 32-bit.
>
> What else would folks want to know?  Here's my django.wsgi script:
>
> import os
> import sys
> sys.path.append("c:/foobar")
> sys.path.append("c:/foobar/foobar_service")
> sys.path.append("c:/python26/lib/site-packages/xlrd-0.7.1-py2.6-
> win32.egg")

If that package was installed correctly in the first place, there
shouldn't be a need to be adding that path explicitly like you are.
This is because the site-packages directory should already be in your
path and by that being so, the .pth in that directory which refers to
the actual egg directory should have been read and the egg directory
also automatically added to sys.path without you doing anything. This
is not relevant to the problem though.

> os.environ['DJANGO_SETTINGS_MODULE'] = 'fabx_service.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> And here's the VirtualHost configuration from httpd.conf:
>
> NameVirtualHost *
> <VirtualHost *>
>  ServerAdmin [email protected]
>  ServerName  foobar.example.com
>  ServerAlias foobar
>  DocumentRoot "c:/foobar"
>  ErrorLog "c:/program files/apache software foundation/apache2.2/logs/
> foobar_error.log"
>  customLog "c:/program files/apache software foundation/apache2.2/
> logs/foobar_access.log" common
>  WSGIScriptAlias / "C:/foobar/foobar_service/apache/django.wsgi"
>  <Directory "c:/foobar">
>    Order allow,deny
>    Allow from all
>  </Directory>
> </VirtualHost>
>
> Is there anything in this morass of configuration that is clearly
> wrong?  Can anyone suggest where I might look next to figure out how
> to run multiple parallel requests through mod_wsgi?

All I can suggest is that your application is using a C extension
module for Python and that modules implementation is not thread safe.
Such problems in pure Python modules will not cause a crash, but for C
extension modules you can get a crash like you see.

What Python modules are you using that you installed yourself and
which have a C extension module component?

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to