Ah, that makes sense!  
 
But I still need help...the reason I want to use the scheduler is to have a 
worker do database inserts and simultaneously update an sql grid of the 
table being inserted into (as described in this question you've already 
seen https://groups.google.com/forum/#!topic/web2py/Hp3o-b7XGQ4).  But I 
want to know how I can tell that the scheduler task has completed.  This 
way I could stop constantly reloading the grid and also give a visual cue 
that the database inserts have completed, i.e. hide my "loading" image.  
How/Where can I detect that the scheduler task has completed? 
 

On Friday, January 3, 2014 9:09:36 AM UTC-8, Anthony wrote:

> scheduler.queue_task() simply inserts a record into the scheduler_task 
> table. However, assuming this code is part of an HTTP request, the insert 
> won't get committed until the request is complete. Yet your code then 
> includes a while loop that will not exit until after the insert (and after 
> the task has completed), which will never happen. I suppose you could call 
> db.commit() right after queuing the task, but then what is the point of 
> using the scheduler? The purpose of scheduling a task in the background is 
> so it can happen outside of a single request-response cycle. Yet, if your 
> request waits until the task is complete before returning, you might as 
> well just do the task directly in the request rather than bothering to have 
> the scheduler do it. 
>
> Anthony
>
> On Friday, January 3, 2014 10:59:29 AM UTC-5, EW wrote: 
>>
>>  I'm having trouble figuring out how to determine when a scheduler task 
>> is done.  My code/scheduler task work is working.  But when I added this 
>> loop, it does not--when I go into the admin interface and look at the 
>> scheduler_task table, the task is not in the table at all.  The printouts 
>> show the task as always being in the QUEUED status.  Is this code somehow 
>> blocking the worker from picking up the task?  What is the best way to 
>> determine when a task has been completed?
>>  
>>  
>>  q = scheduler.queue_task(read_blox, pvars=dict(json_dir_id=r.id),immediate
>> =True) #This line alone works without the following code                 
>>                        
>> task_id = int(q.id)                                         
>> res = scheduler.task_status(task_id)                                     
>>     
>> print res                                         
>> while not res.status == 'COMPLETED':                                     
>>         
>>     res = scheduler.task_status(task_id)                                 
>>         
>>     print res                                         
>> print 'completed'
>>
>>  
>>  
>>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to