Sorry, There is a typo in the previous question. In this sentence "In the 
data table scheduler_worker and scheduler_run I want to delete both 
entries", what I want to say is "scheduler_task" and "scheduler_run" 
tables. In my design, I linked a project with a task by adding an field 
called "processID" for each project which is identical to uuid of 
corresponding task. So that the "project" table and "scheduler_task" table 
could be linked. 

You are right that each time I delete a record in scheduler_task, one 
linked record in scheduler_run need to be deleted as well (assuming that 
the task is completed). 

So I currently I used this script to delete a record in project and 
scheduler_task and scheduler_run:

def delete():
    processID = request.args(0)
    project = db.project(db.project.processID==processID)
    db(db.project.processID==processID).delete()
    task = db.scheduler_task(db.scheduler_task.uuid==processID)
    db(db.scheduler_run.task_id==task.id).delete()
    db(db.scheduler_task.uuid==processID).delete() 

On Saturday, October 4, 2014 2:51:42 PM UTC-4, Niphlod wrote:
>
> On Friday, October 3, 2014 8:19:46 PM UTC+2, Pengfei Yu wrote:
>>
>> Thanks a lot for your detailed explanation for the difference between 
>> Celery and scheduler! I think currently scheduler is enough for our 
>> application, and it is easier to implement (thanks to great work of your 
>> team). May I have one more question. If I want to allow user to delete one 
>> of his projects, which means the task associated with the project will also 
>> be deleted, is there a simple command in scheduler to do that. In the data 
>> table scheduler_worker and scheduler_run I want to delete both entries. 
>> Should I use db(db.scheduler_*.uuid==<an_id>).delete() for both of them, or 
>> there is a single command like scheduler.delete_task(uuid) to do that. I am 
>> not sure if scheduler.terminate(), scheduler.stop_task() or scheduler.kill 
>> can do that. 
>>
>>
> I think you need to make a tour on w2p_scheduler_test 
> <https://github.com/niphlod/w2p_scheduler_tests> beforehand. It seems 
> that some basic concept on what is the scheduler API is somehow obscure to 
> you.
>
> The scheduler is a way to let some task be processed outside web2py. How 
> you (and anyone else) manage the correlation between tasks sent to the 
> scheduler and their own app (e.g., your requirement for them to be 
> "assigned to a project") is entirely up to your application's code.
> The data in scheduler_worker shouldn't matter to you: it's the table where 
> workers coordinate among themselves and carries some statistics around.
> scheduler_task is the table that holds all the tasks you sent (and where 
> you can check their statuses). 
> scheduler_run is the table where return data (if needed) is stored.
> That being said, if you delete a task, its return data (if it's there), is 
> deleted, because there is a foreign key that links the two tables (to be 
> even more plain in explanations, there's no way you can delete a 
> scheduler_task row without deleting ALSO the corresponding records on 
> scheduler_run).
> Ultimately, the kill() and terminate() methods are to there manage worker 
> processes (i.e. the things that are processing tasks), not tasks directly.
> stop_task() instead is a method to manage a possibly RUNNING task (i.e. 
> something that you clearly can't dequeue, because it's already being 
> processed), asking the corresponding worker to stop processing it (so it 
> can be free to process other tasks). calling stop_task on a task that is 
> not RUNNING will result in that task never being processed (it will be 
> marked as STOPPED and nobody will pick that up) 
>

-- 
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/d/optout.

Reply via email to