coto / gae-boilerplate

Google App Engine Boilerplate
https://dev-dot-sandengine.appspot.com/
Other
685 stars 189 forks source link

Rare Coto Bug - Overloaded Memory - Fix Included #299

Open cmumd opened 10 years ago

cmumd commented 10 years ago

Steps:

1) Deploy App to GAE 2) Overload the Memory Usage a few times e.g "Exceeded soft private memory limit of 128 MB with 157 MB after servicing 0 requests total" 3) Try to view the site.. and get error "Error 500: 'uri_for' is undefined"

:+1: The Recent fix added to the repo https://github.com/coto/gae-boilerplate/issues/279 does help for some. However for this instance it does not.

My Fix inside /lib/BaseHandler.py::

def __init__(self, request, response):
        """ Override the initialiser in order to set the language.
        """
        self.jinja2 #Init Jinja2 And Put in the Cache before we go further. Fixes Rare Memory Overload Bug

My theory is that; the first fix helped for any immediate errors that called ErrorHandler or Similar. However; if the error doesn't call an error handler because it is an out of memory error and displays nothing. Then we need this new line to ensure that jinja2 is created successfully, and stored for later use.

I did not commit this because there may a larger issue in the framework, which would cause it so this may be a monkey patch for a greater problem. However, I believe this just an edge case and it took me a while to find this fix since I was stumped at first as well.

Any thoughts welcomed, and thanks for a great framework!