Does anyone know why exceptions are not always passed up the call stack when running a script from the web2py shell?

23 views
Skip to first unread message

Davidiam

unread,
May 25, 2023, 4:38:07 AM5/25/23
to web2py-users
2.22.5-stable+timestamp.2022.06.04.18.13.51
(Running on Microsoft-IIS/10.0, Python 3.9.13)

I am trying to catch errors in web2py shell scripts which are run in batch, but some exceptions are not being passed up the call stack when running in shell mode.

My situation is as follows:
  1. Create the error scenario
    1. empty the languages/plural-en.py in the welcome application
  2. Run a shell script using -M -R 
    1. can be a simple Hello World script
  3. Since it is a shell script, shell.py is used instead of main.py
  4. The exception will be triggered in gluon/languages.py in in the function read_plural_dict_aux() when executing 
    1. return eval(lang_text) or {}
  5. In this scenario, the shell script will fail but give a success return code (rc=0) because the exception is not passed up the call stack
  6. If the welcome application is run via the browser, it uses main.py instead of shell.py and the exception is passed up the call stack and we can see the error code in the error ticket.  
I have tried catching the exception from a few different places and tried custom extensions as well, but I can't catch this exception anywhere in the call stack.

The reason I am trying to solve this is that we have batch jobs that sometimes have failed but give a success return code and so I am trying to find the root cause.  I think that this failure to capture the exceptions may be the cause.  Does anyone have any ideas as to what could be the reason for this? 

Note: If you want to see the call stack, it suffices to delete all the contents of plural-en.py and run the welcome app from the browser.  In the error ticket, the call stack will basically the same as the shell version as of the call to compileapp.py

Kind Regards,
David
Reply all
Reply to author
Forward
0 new messages