Hi Graham,

Yea, I picked up that link from your answer on SO to a similar question
of mine. +1 :P

Thanks,
Aiden 

On Thu, 2009-07-09 at 11:27 +1000, Graham Dumpleton wrote:
> That Apache runs as a multi process web server on UNIX may also be a
> contributor to why it wasn't working as you expected. Have a read of:
> 
>   http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading
> 
> Graham
> 
> 2009/7/9 aiden <[email protected]>:
> >
> > The cause turned out to be my misunderstanding:
> >
> > class SomeClass:
> >    my_list = []
> >    def add_to_list(self, item):
> >        self.my_list.append(item)
> >
> >   def print_list(self):
> >        for l in self.my_list:
> >            # some action
> >
> > I didn't realize that the
> >
> >   my_list=[]
> >
> > Would create a shared list instance between all instances of the
> > class ... Duh! As a result, threads were all appending to that
> > instance.
> >
> > On Jul 8, 12:44 pm, aiden <[email protected]> wrote:
> >> Hello!
> >>
> >> I am running into a problem with mod_wsgi. Variables are accumulating
> >> data across requests. A simple example might be:
> >>
> >> def print_list( sapi, list ):
> >>     for item in list:
> >>         sapi.write(item)
> >>
> >> In one request the list contains 5 items (as it should). In subsequent
> >> requests the list contains 5,10,15,20 items and so on. Even with `del
> >> the_list` at the end of each request. I am sure that no logic or state
> >> in the application itself is the culprit.
> >>
> >> Interestingly the list goes to 5,10,15,20,15,30,35 and then back to 5.
> >> If I turn KeepAlive off in Apache, I get different results. Simple
> >> test-cases do not reproduce the problem, only when the code gets
> >> sufficiently large does the problem occur, leading me to think that
> >> its cause is rather subtle. Has anyone else had experiences with data
> >> persisting/repeating across requests?
> >>
> >> Thank you in advance
> > >
> >
> 
> > 


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