On Thursday, September 8, 2016 at 6:27:15 AM UTC-7, Erwn Ltmann wrote:
>
> Hi Dave,
>
> thx for your response. I'm sorry, but it doesn't helps me. My problem 
> concerning the usage of scheduler_task queueing. The web2py scheduler 
> transforms automatically the dictionary parameter 'pvars' into a string 
> represented JSON in order to save this value as VARCHAR2(512) into the vars 
> column of database (oracle) table scheduler_task. So far so good. But IMHO 
> with unnecessary quotes at begin and end. The scheduler part of web2py 
> tried to read scheduler records and fails because this (damn) extra quotes.
>
> E.
>
>
I don't use Oracle and I don't have JSON arguments for tasks (yet), so I 
can't tell you if the "problem" is with the queue_task() call or with the 
Oracle driver.  Niphlod is the Scheduler authority, having done the rewrite 
of it.  I'm not sure who our local Oracle expert is.

Does the error occur when you access vars[0] from your task (launched by 
the Scheduler?)  Or does it occur when the Scheduler is trying to start up 
your task?  Also, are you accessing the Scheduler tables directly?  I don't 
think you should be doing that ... for one thing, that's an implementation 
detail that's not an official API and is subject to change.  And I don't 
think it's needed, as your launched task is passed the args.

/dps

On Thursday, September 8, 2016 at 4:01:37 AM UTC+2, Dave S wrote:
>>
>>
>>
>> On Wednesday, September 7, 2016 at 5:30:49 PM UTC-7, Erwn Ltmann wrote:
>>>
>>> Hi, 
>>>
>>> I'm used to create a new task for example: 
>>>
>>> scheduler.queue_task( 
>>>       "a_task", 
>>>       pvars = dict(csid=row.id, csname=row.name, action=row.action), 
>>>       ... 
>>> ) 
>>>
>>> In the past (version 2.10.1), everything was fine. Within the current 
>>> version (2.14.6) I have some trouble. See this code for example: 
>>>
>>> for row in db(db.scheduler_task.group_name == "agents").select( 
>>>                 db.scheduler_task.ALL): 
>>>  ... 
>>>  pvars = json.loads(row.vars) 
>>>
>>> ... will raise this exception: 
>>>
>>>   ... 
>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 384, in 
>>> raw_decode 
>>>     raise ValueError("No JSON object could be decoded") 
>>> ValueError: No JSON object could be decoded 
>>>
>>> The reason is a quoted string in column 'VARS' in table 'SCHEDULER_TASK' 
>>> (no quotes in web2py's old version 2.10.1). 
>>>
>>> A new value for 'VARS' with quotes for example: 
>>>
>>> '{"action": "script", "csname": "list", "csid": 121}' 
>>>
>>> I can skip the quotes with a trick: 
>>>
>>> pvars = json.loads(row.vars[1:-1]) 
>>>
>>> But, it is not a general solution. The same problem appears for column 
>>> 'ARGS' in scheduler.py when I process the tasks: 
>>>
>>>   File "/export/home/armadm/dev01/release/web2py/gluon/scheduler.py", 
>>> line 311, in executor 
>>>     args = _decode_list(loads(task.args)) 
>>>   File "/usr/local/lib/python2.7/json/__init__.py", line 338, in loads 
>>>     return _default_decoder.decode(s) 
>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 366, in decode 
>>>     obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 
>>>   File "/usr/local/lib/python2.7/json/decoder.py", line 384, in 
>>> raw_decode 
>>>     raise ValueError("No JSON object could be decoded") 
>>> ValueError: No JSON object could be decoded 
>>>
>>> I use Oracle as database: 
>>>
>>> SQL> desc scheduler_task 
>>>  Name                                      Null?    Type 
>>>  ----------------------------------------- -------- 
>>> ---------------------------- 
>>>  ID                                        NOT NULL NUMBER 
>>>  ... 
>>>  ARGS                                      VARCHAR2(512) 
>>>  VARS                                      VARCHAR2(512) 
>>>
>>> Any ideas? 
>>>
>>> Thx, Erwn 
>>>
>>
>> the vars field is a dict, with the var names as keys and the stuff you 
>> want to pass as the values.  Both are strings.
>>
>> I use a single var in my code, the name is "where" and the value is a 
>> path.  So I do
>> if vars["where"]:
>>    mywhere = vars["where"]
>>
>>
>> No stripping of quotes is needed to get the path.
>>
>> /dps
>>
>>

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

Reply via email to