Well, after some digging into source code I found the solution. In 
gluon/scheduler.py,

def executor(queue, task, out):
     W2P_TASK = Storage({'id' : task.task_id, 'uuid' : task.uuid})
    _env.update({'W2P_TASK' : W2P_TASK})

W2P_TASK is an environment variable. So, to get the task id,

task_id = W2P_TASK.id


On Thursday, 29 August 2013 19:14:25 UTC+5:30, Manoj Kumar M wrote:
>
> Is it possible to get the task id of the current task from within the task?
>
> for example:
> def task_add(a,b):
> task_id = scheduler.my_id() # get current task id
>     return a+b
>
> scheduler = Scheduler(db, tasks=dict(demo1=task_add))
>
> scheduler.queue_task('demo1', pvars=dict(a=1,b=2),
>                      repeats = 0, period = 180)
>

-- 

--- 
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