Warning: I'm still new to python and web2py so this may be wacky, but...

Could you make a cached method with side-effects and an infinite expiry? 
 Since RAM would always be cleared on a restart it would theoretically only 
ever be run on cold start.

first_time = False
def first_start_check():
    global first_time; first_time = True
    return True

cache.ram('startup', lambda: first_start_check(), time_expire=None)
if first_time == True:
    print "It's the first time!"


On Thursday, May 31, 2012 5:28:21 AM UTC+1, Jonathan Lundell wrote:
>
> On May 30, 2012, at 7:13 PM, Massimo Di Pierro wrote:
>
> you can make a cron job in admin @reboot
>
>
> It'd have to be soft cron, yes? And it wouldn't run until after my app 
> services its first request after restart, if I remember my soft cron logic 
> aright.
>
>
> On Wednesday, 30 May 2012 21:10:13 UTC-5, Jonathan Lundell wrote:
>>
>> I've got an application that uses memcached. I'd like to recognize when 
>> web2py gets restarted (mod_wsgi, fwiw) so I can flush my cache. No doubt I 
>> can figure something out, but I'm sure I must be missing something obvious. 
>> (My motivation: in my development environment, I sometimes blow away my 
>> database when installing and starting a new copy of the app, and things get 
>> confused when the cache is still holding data from the earlier run.)
>
>
>
>

Reply via email to