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