Scenario: In one of my small enterprise app, my action is time
consuming, so I use cache. Furthermore, I setup a cron job to "touch"
this action frequently, hoping that other real users will be benefited
by always have cache hits. Example as below.

@cache(request.env.path_info,time_expire=1800,cache_model=cache.ram)
def index():
    result = do_a_time_consuming_job()
    return {'result': result}

# the crontab file
*/30    *       *       *       *       root **default/index


Nice plan, huh? But it has no effect. Because each time the cronjob is
seemingly invoked in a separated process space (via "web2py -P -N -M -
S myapp/default/index -a <recycled>"), so the main process's cache.ram
is not touched.

So, is it possible to change the implementation, let the "visit my
action" cronjob be done by this way?
    urllib.urlopen('http://localhost:8000/myapp/default/index').read()


By the way, my current workaround is to write my crontab file like
this:
    */30        *       *       *       *       root 
**applications/myapp/cron/trigger.py
and my trigger.py is based on urlopen(...).read() mentioned above.
The workaround works, but I don't like the fact that it hardcode the
app name (as well as the port).

PS: Using cache.disk() is not (yet) a workaround for web2py_win.zip. I
report a bug about that in another post.

So, what's your opinion?


Regards,
Iceberg

Reply via email to