Blind leading the blind here as I am new to web2py, but I saw something in 
the docs that may achieve what you are after:

http://web2py.com/book/default/chapter/04#Cron

In the crontab ability of web2py, there's a @reboot condition (of web2py, 
not the machine) -- meaning a script is run whenever web2py 
starts/restarts.   Maybe put your code there?

I've also read a few places that the scheduler ability in web2py is favored 
over crontab.  I'm working my way through this video now to learn scheduler 
vs. crontab.

I'm guessing with either method you could do your lookups, store the 
results in a table, and have quicker access to the lookups... Maybe even 
adding @cache decorators to the actual lookups to further reduce lookup 
times.

On Tuesday, February 4, 2014 7:33:35 PM UTC-6, [email protected] wrote:
>
>
> Hi,
> I am using web2py v2.8.2.  My command line to launch web2py is "python 
> web2py -i 0.0.0.0" .  I am using python 2.7.5
> I have a fair sized dataset, takes about 10sec to load from the datafiles 
> and perform some calc for lookup.
>
> Code is something like this:
> lookup_data = fn_datalookup(filespath)
>
> I want to expose the lookup_data to a few controllers, but i want web2py 
> to load it only once and make it available to controllers that make the 
> request. Yes, global variable. Load once, read many as long as web2py is 
> up. Reason is : I don't want to loose 10sec on every request that needs to 
> work on this dataset.
>
> I tried the following:
> 1. In a new model file: Call gets executed by all controllers, every time, 
> i.e. 10sec loss on every request in the app. Not a recommended approach 
> (based on documentation). Hence not good
>  
> 2. In specific controllers: Takes 10sec to load on all valid calls, but 
> still not good. I don't want to loose 10sec on all valid requests.
>
> During web2py startup, can i load once and make it available as a global 
> read-only? If yes, how?
>
> If this has been answered before, please point to the post and i will 
> gladly read and learn from the answered post. My search didn't yield the 
> results.
>
> Another problem:
> I noticed that the memory usage(VSZ, RSS) keeps going up and never came 
> down in both the above cases. i.e. every new call increased the memory 
> usage. I waited for more than an hour (with no activity), still didn't come 
> down
> Web2py runs as a single process, doesn't spawn any new process on 
> requests.... Where can i find documentation on how web2py allocates and 
> deallocates resources and some best practices when working on long running 
> processes, large datasets.
>
> Thanks,
> Yogesh
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to