Error in scheduler.py when scheduled task uses a jsonrpc webservice

15 views
Skip to first unread message

Lisandro

unread,
Jul 30, 2015, 12:06:14 PM7/30/15
to web2py-users
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

Lisandro

unread,
Aug 1, 2015, 10:29:32 AM8/1/15
to web2py-users
Nevermind, it was my bad, scheduler.py was running ok and awesome all the time :)

I was connecting to older version of my own webservice, wich was working on two domains. Sorry :P
Reply all
Reply to author
Forward
0 new messages