Closed originell closed 11 years ago
Weird! Thanks for this
Totally.. but as I said I consider this more of a workaround than a true fix :)
I am still getting KeyErrors
even on the newest version.
They are infrequent, but they always happen on the first block of the template. The issue is on line 77 of TemplateTimings.py, key='blocks'
if name_self not in results.timings[key] and should_add(name_self):
awww man…
does that happen for you on every page or just a specific one?
@trwalzer could you please post the template that is causing you issues? I will add some failsafes to it and make it print out some useful info instead of KeyErroring
It happens inconsistently, but I've seen it on multiple pages. When it does happen it ALWAYS happens on the first block of the template. I've seen it on both the admin site and the regular site. They use different base templates, so its not just one template either. Here is the top of the template, it fails on the {% block doctype %}
tag.
{% load i18n satchmo_category satchmo_google satchmo_util satchmo_currency satchmo_discounts app_plugins normalize_decimal %}
{% load url from future %}
{% block doctype %}
<!DOCTYPE html>
{% endblock %}
I will keep an eye on it and when it happens again I'll grab more info from the error page.
for me it always happened on the admin page (django 1.5)… this might sound crazy, but could that be a thread-related issue?
It might be, what version of Python are you guys using? The lookup is on a defaultdict() which in theory should never KeyError because any missing keys are automatically inserted and the default value returned.
Perhaps the defaultdict is turning into a normal dictionary somehow? :/
Anyhoo I've added a hack that might fix it (update is on PyPi), let me know how it goes.
I'm on Python 2.7.2, what about you?
2.7.3 over here. I'll pull the latest and keep an eye on things.
defaultdict
is in python's collections
since 2.5.. something stinks here
Well I have seen this issue before, but not since the original pull request. I will revert it on my machine and do some digging tomorrow
I think the issue is related to running New Relic and Template Timings at the same time. I realized that when I was running both, the KeyError issue would sometimes be raised by New Relic, other times it would be raised by Template Timings. So I'm not sure who is to blame, but it seems that they don't play well together.
I'm not using New Relic, so that's at least not related to my error back then.
Does this still happen, even with the latest version? If this occurs again could I please have the key it is trying to find and the value of results.timings, otherwise I haven't got a chance of fixing this.
For some weird reason I get
KeyError
s in this part…I'm not exactly sure why they happen, because as far as I understand it they should not.
Sadly I'm under a time constraint right now, so I had to "workaround" this, rather than truly fix it. Below is the workaround, which uses the wonderful
setdefault