its more of an architectural problem than a web2py one .... to be sure that
the tasks are there you may have to check for their presence on the
scheduler_task table. There is the uuid column that is enforced as unique,
so you can use it to query the table safely.
Now, the problem is that you generally don't want to do a query at every
request: you may want to look at cron's @reboot or use a little trick using
cache....
lock_tasks = cache.ram('lock_tasks', lambda: request.now, time_expire=120)
if lock_tasks == request.now:
#do your checks here
What it does? Stores request.now in cache for 120 seconds. Next, it checks
if the value retrieved from the cache is the same one (meaning that the
cache value has been refreshed in the same request) .... the code in the
section will be executed at most every two minutes (always assuming that
requests come along)
Please mind that if you put this in models it works well for web requests,
but the scheduler executes models too and every time in a fresh process, so
cache.ram doesn't survive... to eliminate that issue, you may have to put
this logic too
if not global_settings.cmd_options.scheduler:
#this piece of code is not running on the scheduler
--