One possibility is that although you think you are using daemon mode,
you aren't, and that Apache compiled with worker MPM. This can occur
if you don't have WSGIProcessGroup directive set properly to refer to
daemon process group setup using WSGIDaemonProcess.

Post the mod_wsgi bits of the Apache configuration, include any
VirtualHost, Directory, Location context they are defined in.

In your per request debug also print out:

  print >> sys.stderr, environ.get('mod_wsgi.process_group')
  print >> sys.stderr, environ.get('mod_wsgi.application_group')

  print >> sys.stderr, environ.get('wsgi.multithread')
  print >> sys.stderr, environ.get('wsgi.multiprocess')

If mod_wsgi.process_group prints out as empty string, you are running
in embedded mode. If multithread is true shows that running in
multithreaded process and not single threaded process as you expect
and thus also why result may be different each time.

You could also print out:

  print >> sys.stderr, threading.currentThread()

to show what Python thinks the thread is each time.

Graham



2008/10/3 William Dode <[EMAIL PROTECTED]>:
>
> Maybe more clear :
>
> #!/usr/bin/python
> import cgi
> import threading
> import sys
> import os
>
> class MyLoc(threading.local):
>    def __init__(self):
>        print >> sys.stderr , 'init'
>
> myloc = MyLoc()
>
> def application(environ, start_response):
>    status = '200 OK'
>    myloc.i = 0
>    print >> sys.stderr, 'pid: %s id: %s id.__dict__: %s' % (os.getpid(), 
> id(myloc), id(myloc.__dict__))
>    output = ''
>    response_headers = [('Content-type', 'text/html'), ]
>    start_response(status, response_headers)
>
>    return [cgi.escape(output)]
>
> [Fri Oct 03 11:37:04 2008] [error] init
> [Fri Oct 03 11:37:04 2008] [error] pid: 1836 id: 3067827220 id.__dict__: 
> 3067884244
> [Fri Oct 03 11:37:04 2008] [error] init
> [Fri Oct 03 11:37:04 2008] [error] pid: 1836 id: 3067827220 id.__dict__: 
> 3067885740
> [Fri Oct 03 11:37:05 2008] [error] init
> [Fri Oct 03 11:37:05 2008] [error] pid: 1836 id: 3067827220 id.__dict__: 
> 3067884244
> [Fri Oct 03 11:37:05 2008] [error] init
> [Fri Oct 03 11:37:05 2008] [error] pid: 1836 id: 3067827220 id.__dict__: 
> 3067885740
>
> init should not be called and __dict__ should not be different
>
> The same with wsgiref :
> from wsgiref.simple_server import make_server
> make_server('',8080,application).serve_forever()
>
> init
> pid: 1868 id: 3082036284 id.__dict__: 3082022260
> pid: 1868 id: 3082036284 id.__dict__: 3082022260
> pid: 1868 id: 3082036284 id.__dict__: 3082022260
> pid: 1868 id: 3082036284 id.__dict__: 3082022260
> pid: 1868 id: 3082036284 id.__dict__: 3082022260
>
> I'll look if i can reproduce this with the code of _threading_local
>
>
> --
> William Dodé - http://flibuste.net
> Informaticien Indépendant
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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