Thank you all for your help.
I've tried to log the value of routers.BASE.applications, but I'm facing an 
weird situation:

The traceback shows that the error is at line 1241 of gluon/rewrite.py (the 
second line):

if self.args:
    if self.args[0] in self.functions or self.args[0] in self.controllers or 
self.args[0] in applications:
        self.omit_function = False


First I added some lines in order to log the content of "applications":

if self.args:
    mylog = open('mylog.txt', 'a')
    mylog.write('%s\n' % applications)
    mylog.close()    
    if self.args[0] in self.functions or self.args[0] in self.controllers or 
self.args[0] in applications:
        self.omit_function = False

Having made that change, I restarted uwsgi and reproduced the error. Then I 
checked the log, but I only saw a lot of this:

[regionoeste]
[regionoeste]
[pescaregional]
[pescaregional]
[pescaregional_panel]
[pescaregional_panel]
[blogmedios]
[blogmedios]
[blogmedios]

There was nothing like "ALL" or anything weird. Every logged line is a list 
of one only app (I think that's because I use exclusive_domain=True, so 
each app can be accessed only through a specific domain). 


Then I tried to catch the error to log anything that could help, so I did 
this:

if self.args:
    try:
        if self.args[0] in self.functions or self.args[0] in self.controllers 
or self.args[0] in applications:
            self.omit_function = False
    except TypeError:
        mylog = open('mylog.txt', 'a')
        mylog.write('%s\n' % applications)
        mylog.close()

Again, restarted uwsgi and reproduced the error.
To my surprise, nothing was logged (the log file hadn't been even created).
But the scheduler task had indeed failed with this traceback:

File "applications/pescaregional/modules/virtual_methods.py", line 248, in 
contenido_url return URL(a=current.CONFIG.cliente, c='default', f=f, args=[
contenido.id, contenido.slug], extension='', scheme=True, host=current.
CONFIG.dominio) if f else None 
File "/var/www/medios/gluon/html.py", line 391, in URL args, other, scheme, 
host, port, language=language) 
File "/var/www/medios/gluon/rewrite.py", line 197, in url_out function, args
, other, scheme, host, port, language) 
File "/var/www/medios/gluon/rewrite.py", line 1366, in map_url_out File 
"/var/www/medios/gluon/rewrite.py", line 1292, in acf def acf(self): 
File "/var/www/medios/gluon/rewrite.py", line 1241, in omit_acf try: 
TypeError: 'in <string>' requires string as left operand, not long


Notice the traceback is slightly different than the original one.
While the last line of the original traceback showed this:

File "/var/www/medios/gluon/rewrite.py", line 1241, in omit_acf if self.args
[0] in self.functions or self.args[0] in self.controllers or self.args[0] in
 applications: TypeError: 'in ' requires stringas left operand, not long

... in the last test I did it shows this:

File "/var/www/medios/gluon/rewrite.py", line 1241, in omit_acf try: 
TypeError: 'in <string>' requires string as left operand, not long


Meaning that the code is indeed running with the try:except block I added, 
but somehow the error isn't cached, although the scheduler task fails and 
reports that error :/


Some additional info that worths mention:

   - I have a development environment with the exact same software and 
   library versions (nginx, uwsgi, postgres, redis, web2py), but I can't 
   reproduce the error there.
   
   - My production environment grows automatically: an average of 10 new 
   websites are created per month; each time a new website is created, a 
   scheduler task installs a copy of two web2py applications I developed; at 
   this time, the web2py instance is running about 600 apps. The problem 
   started to happen recently, and I can confirm that it happens in all the 
   new websites, while it doesn't happen in the old ones. Could the problem be 
   related to the amount of installed apps? It shouldn't, right?
   
   - I can also confirm that nothing was changed, there wasn't any server 
   library update, the application code hasn't changed (it's cloned from a 
   local repository that has had the same version for months).


It's very weird.
In the meantime, I'll make a fix to my app, to pass the args to URL as 
strings, specially in the cases where the code is run within the scheduler 
environment. 

Let me know if you notice something or if you can think of any other test I 
could do.
Thanks a lot!


El lunes, 3 de septiembre de 2018, 16:28:53 (UTC-3), Anthony escribió:
>
> On Monday, September 3, 2018 at 1:47:41 PM UTC-4, Leonel Câmara wrote:
>>
>> Since it only happens with some installations, my guess is that this is 
>> happening in the case where this is the only web2py app (not even the admin 
>> or welcome is installed). In this case the list of applications is probably 
>> a single string instead of a list. 
>>
>> Are you setting routers.BASE.applications somewhere in your routes.py?
>>
>> Otherwise, I think this is definitely a web2py bug where the default 
>> value of routers.BASE.applications which is a string 'ALL' is being passed 
>> without being converted to a list of all applications.
>>
>
> Doesn't look like routers.BASE.applications is set in routes.py, but it 
> appears that somehow in the context of the scheduler, the default value of 
> 'ALL' is not getting converted to a list of apps. It's hard to track down 
> exactly where things are going wrong.
>
> Lisandro, maybe confirm the value of routers.BASE.applications at that 
> point in rewrite.py by printing/logging it.
>
> Anthony
>  
>

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