Read: http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
It talks about process/threading model of Apache/mod_wsgi and has some notes about data sharing between requests and processes. Graham 2010/1/13 Honril <[email protected]>: > hello; > > i don't know if this belongs here, but i did not know where else to > turn too. > > i'm running Apache with mog_wsgi (no mod_python), just to see how it > works and play with it a bit. I would expect the code below to always > out put "tClass\nsomething; "; though that is not the case. the > "\nsomething; " part is repeated depending on how many times i reload > the page. (actually it will be repeated for every time i reload the > page, until it starts from one occurence and adds "\nsomething;" for > every request again. there seems to be no real system behind it. i > expect this is due to the use of multiple process and that every > process keeps a different value for var3 in tClass) > > class tClass: > def __init__(self, var1, var2=[]): > self.var1 = var1 > self.var2 = var2 > > def run(self): > return self.var1 + ''.join(self.var2) > > def add(self, value): > self.var2.append(value) > > > def application(environ, start_response): > status = '200 OK' > output = '' > > contentsType = 'text/plain' > > t = tClass('tClass') > t.add('\nsomething; ') > > output += t.run() > > response_headers = [('Content-type', contentsType), ('Content- > Length', str(len(output)))] > start_response(status, response_headers) > > return [output] > > > > i find it strange that var3 is kept between requests even though a new > instance of tClass is created for each request. if i change line 19 > from > t = tClass('tClass') > to > t = tClass('tClass' []) > the output is exactly what i expect it to be ("tClass\nsomething; " > for every single request). So i'm at a loss. I don't know when or why > some variables are kept between requests and other are not. if there > is someone who could clear this up for me, or point me to > documentation that would explain this it would be greatly appreciated > (i did read large parts of the documentation i could find on > http://code.google.com/p/modwsgi, though i did not find anything that > would explain this). > > i haven't done anything with the configuration > > output would be something like > > 1) > tClass > something; > 2) > tClass > something; > something; > ... > 7) > tClass > something; > something; > something; > something; > something; > something; > something; > 8) > tClass > something; > 9) > tClass > something; > something; > 10) > tClass > something; > something; > something; > something; > something; > something; > something; > something; > > and so on > > -- > 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. > > > >
-- 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.
