I've been several hours trying to figure out what's happening, thinking 
that my code had a bug. But I think the problem is in scheduler.py. I 
think, not sure.

The simplified scenario is the following. Two web2py apps running on the 
same web2py installation.


App "A" defines a public jsonrpc service with a simple "test()" function. 
All defined in controller ws.py:

# -*- coding: utf-8 -*-
# appA/controllers/ws.py
 
from gluon.tools import Service
service = Service()


def call():
    session.forget()
    return service()


@service.jsonrpc
def test():
    return True



App "B" has the function "newsletter()" defined in db.py model, that 
consumes the webservice:

# -*- coding: utf-8 -*-
# appB/models/db.py

# ... here, the table definitions, etc

def newsletter():
    from gluon.contrib.simplejsonrpc import ServerProxy
    ws = ServerProxy(CONFIG.url_webservice)
    ws.test()
    return True



When I call the "newsletter()" function from inside app B (for example, 
from a controller), the function works ok: it connects to the webservice, 
calls the webservice function, and returns True.
However, when I schedule the "newsletter()" function as a scheduler task, 
it always fails with this traceback:

Traceback (most recent call last): 
    File "/home/gonguinguen/medios/gluon/scheduler.py", line 315, in 
executor result = dumps(_function(*args, **vars)) 
    File "applications/demo/models/db.py", line 837, in newsletter 
ws.test() 
    File "/home/gonguinguen/medios/gluon/contrib/simplejsonrpc.py", line 
108, in <lambda> return lambda *args: self.call(attr, *args) 
    File "/home/gonguinguen/medios/gluon/contrib/simplejsonrpc.py", line 
140, in call self.error.get('data', None)) 
    File "/home/gonguinguen/medios/gluon/contrib/simplejsonrpc.py", line 
37, in __init__ value = "%s: %s\n%s" % (code, message, '\n'.join(data)) 
TypeError


One detail that has been really confusing me: if I rename the "test" 
function to "get_stats", it works. Don't ask me how. I've done a search in 
ALL files of both apps, the "get_stats" function isn't defined anywhere, it 
doesn't exists. The scheduled function fails always when calling the 
webservice method, except when the method is called "get_stats". Really 
confusing. I've found a "get_stats" function defined in 
gluon/contrib/memcache.py, but I don't know if it has something to do with 
this scenario.

If anyone is seeing something that I don't, please point it out! I'm 
pulling my hair off with this :P

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