On Feb 14, 11:30 am, Eric Ka Ka Ng <ngk...@gmail.com> wrote: > > however, in my case, I have a variable defined inside a module that > would be imported (and cached) , but i would like to have that > variable be re-initialized in every requests. In particular, with this > example > > ### mymodule.py > counter = 0 > def increment(): > global counter > counter += 1 > return counter > > ### myhandler.py > import mymodule > > print "Content-Type: text/plain" > print "" > print "My number: " + str(mymodule.increment()) > print "My number: " + str(mymodule.increment()) > > I would like to "disable" the caching and to have > "counter" being re-initialized to 0 in every request. > > Any way to achieve this?
### mymodule.py counter = 0 def increment(): global counter counter += 1 return counter de reset(): global counter counter = 0 ### myhandler.py import mymodule def main(): mymodule.reset() respond() def respond(): print "Content-Type: text/plain" print "" print "My number: " + str(mymodule.increment()) print "My number: " + str(mymodule.increment()) if __name__ == '__main__': main() -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appeng...@googlegroups.com. To unsubscribe from this group, send email to google-appengine+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.