On 26 Jul 2014, at 7:13 AM, lucas <sjluk...@gmail.com> wrote:
> i have it in a module and under that module i have the variable setup as a 
> global variable.  wherein, if the variable is empty upon using it, i load the 
> list of lists from a text file.  if it is not empty, then i just use it.  so 
> in that case, is there just the single instance in memory, no matter the 
> number of users or sessions?  thanx, lucas

One instance per process (the best you can do, since processes don't share 
memory spaces) (well, not as a rule). You could also do your initialization 
unconditionally directly in the module (not in a function, or in a function 
called from the the modules top level); it'll happen on the first import. 

If you trigger initialization from a global variable (in the module), keep in 
mind the possibility of a race causing multiple initializations on parallel 
threads. Probably rare enough that you don't care, as long as there's no 
possibility of exposing some inconsistent state during initialization, but 
worth thinking about. I'm pretty sure that Python protects you against that if 
you do your initialization at import time.


Side note: when you're thinking about this kind of thing, you want to think in 
terms of requests, rather than users or sessions. Requests are the basic unit 
of execution for web2py. Sessions are just persistent objects that can be 
shared across a set of requests (using cookies), and users are just another 
persistent database entity.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to