On Wed, Apr 13, 2011 at 6:48 AM, NiL <[email protected]> wrote:
> 2/ in my use case get_user_options is very both very network and cpu > intensive, so I tried to setup a memoized decorator, otherwise the > computing is done for every instance call. That is, if I set some data > in the 'values' of the forms, once for each field > This is probably not going to work the way you would expect it to when you push to production. The reason for this is that the memoized object will be thread local, and (unless you only have one thread) the web browser sending in the request may hit any of the possible threads whenever the request comes in. As a result, you are likely going to be storing the data multiple times, in multiple threads. Since those threads won't (necessarily) automatically restart, or have any way of periodically purging the data, those objects will live forever, gradually consuming more and more memory until the whole system comes down. You really only have two options to solve this (that I can think of right now): 1. Use a thread safe version of the Borg pattern, and store the shared data in a common memory area. Since you are writing your own class, you can implement whatever purging mechanism you like. 2. Find a way to generate the data you need that is less expensive. If you get that down to a low enough cost, you may not care any more. I'm sorry, I just don't see other viable options. -- Michael J. Pedersen My IM IDs: Jabber/[email protected], ICQ/103345809, AIM/pedermj022171 Yahoo/pedermj2002, MSN/[email protected] ---------- All humans fail, in both great and small ways we fail continually. Machines fail too. Computers are machines that are managed by humans, the fallout from failure can be spectacular. Your responsibility is to deal with failure, to anticipate it and to eliminate it as far as is humanly and economically wise to achieve. Are your actions part of the problem or part of the solution? -- You received this message because you are subscribed to the Google Groups "TurboGears" 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/turbogears?hl=en.

