queue_task does a validate_or_insert, because its meant to be used to queue 
the tasks .... 
if you want to use that you should enforce your own fixed uuid and pass 
that to queue_task()... validation will fail (because the uuid is declared 
as unique, and another row with that id sits on the table yet) and so no 
new insert will be done.
PS: you don't need to put in the application_name, it's filled 
automatically.
PS2: a 5 seconds period is rather small, with the default heartbeat don't 
expect to get exactly 20 runs in one minute....

if you put this in models a query is fired at every request to check if the 
table is empty: if you're fine with that than I'm glad you solved the 
problem ^_^

On Tuesday, January 22, 2013 4:01:01 PM UTC+1, Stormcrow wrote:
>
> Hi again,
> Thanks for the tips! What I ended up doing is creating a model file 
> containing the following:
>
> import datetime 
> if db(db.scheduler_task).isempty():    
>       
> db.scheduler_task.update_or_insert(db.scheduler_task.task_name=='my_function',
>               application_name='my_app',
>               task_name='my_function',
>               function_name='my_function',
>               repeats =  0, 
>               period = 5,
>               retry_failed = -1
>     )
>     db.commit()
>
> There is perhaps a less verbose way to do it, I didn't check which fields 
> have defaults. I tried the same thing using the *queue_task *function but 
> it seemed to cause multiple tasks to appear again,* update_or_insert*solved 
> that problem.
>

-- 



Reply via email to