New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Environment and Macro are None in compiled template #481
Comments
i see the same issue and because of this we cannot use compiled templates unfortunately i can reproduce it only in our live environment (maybe because |
I will close this because I can't reproduce it at all. If someone has more information please make a new ticket with more information. |
@mitsuhiko Can you suggest any debug code I can add to diagnose or create a test case? I am lost because it only happens in a fraction of requests and in a way that I have not been able to reproduce. |
If the environment is None the only real explanation I have is that the interpreter initiated a module shutdown which means that the last reference to the module was cleared. I am not sure what would cause this. |
I assume this always happens with |
So just looking at the code the module package reference in I imagine that this could happen if you have an application that shuts down execution but outstanding HTTP requests are still in the air. |
To investigate if this is the case you could do this: import sys
env = Environment(loader=ModuleLoader(...))
sys.modules[env.loader.package_name] = env.loader.module This changes the weak reference to a strong reference. If that stops the problem then your issue is that requests are in flight while the environment was already collected. |
I have never experienced the problem during
This may well be the case. I am deploying to the Google App Engine environment which can shut down application instances at any time. I will deploy your suggestion and report back if the exception reoccurs. |
i am sorry this is getting closed, but as i am not able to provide more information, can't really complain. however, as it was 100% reproducible in our live environment, it seems a bit dangerous to keep this feature without any kind of caveat for the users. it's not big fun to deploy this to 100k live users and start seeing mysterious 500s. |
@squfrans which feature are you referring to here? The compiled template loader is working just fine for the vast majority of users from what I can tell. I assume this is most likely in combination with a specific setup. |
For what it's worth the |
i am referring to the feature of compiled templates (not necessarily the template loader, the errors were runtime errors while the template was being rendered). judging by the fact that there is only 2 people experiencing this issue, i am inclined to agree that it must be working for the majority of the users :} unfortunately i cannot use them, exactly in a high traffic website where the gain would be the biggest. |
Just started seeing this as well. Flask app is deployed through uWSGI. I keep getting this:
and always on the same precompiled template. Update 1: Update 2: |
I'm using Jinja 2.8 and occasionally get errors with similar traces to the following:
I took a look at the Jinja2 source code, but wasn't able to see at quick glance where the environment variable is being set in the globals of the compiled template module.
The errors happen infrequently and I haven't been able to find the particular conditions to reproduce the problem. However, it happens on a regular basis.
Can you please suggest how I can debug the problem? Are there any debug switches I can use to figure out what's going on?
The text was updated successfully, but these errors were encountered: