Comments (2)
[Markdown messed up my report. Let me try again.]
I think the LRUCache class in Jinja2 has a bug. The problem is that the "getitem" method may mutate the cache, but that method does not acquire the write lock, "_wlock".
For example, here's one scenario:
- Thread A calls "getitem" with the key "K".
- "K" is not the last element of the queue, so Thread A removes it.
- Thread A is suspended before it appends "K" to the queue.
- Thread B calls "setitem" with the key "K".
- Thread B finds "K" in the "mapping" dictionary.
- Thread B tries to remove "K" from the queue.
- The queue raises an exception, because it does not contain "K".
In my project I've seen the "setitem" method raise a KeyError. I assume that there's a similar execution scenario behind those exceptions, but I could be wrong.
In any case, I think "getitem" clearly needs to acquire "_wlock" before it removes and appends keys.
from jinja.
To add to this 2 year old ticket... I have also observed the same exception in my system.
[Tue Feb 12 19:48:16 2013] [error] File "/local/python_envs/www/local/lib/python2.7/site-packages/jinja2/utils.py", line 473, in __setitem__
[Tue Feb 12 19:48:16 2013] [error] del self._mapping[self._popleft()]
[Tue Feb 12 19:48:16 2013] [error] KeyError: '_breadcrumbs.html
from jinja.
Related Issues (20)
- Introducing `NeverUndefined` HOT 3
- Leading newline after `trans` block with Jinja trim options results in translation lookup failure
- Indent filter fails confusing if input is not string HOT 3
- test_striptags regressed with markupsafe 2.1.4 HOT 1
- Is it not possible to utilize a test adorned with the @pass_context decorator in the select function?
- add sort_keys argument to `tojson` filter HOT 2
- `tojson` always do autoescape HOT 2
- Native types in macros works for list but does not work for int HOT 2
- Template globals not visible in {% import %}'ed file when it's {% include %}'ed by another file
- Flake8 error B036 reported by updated flake8-bugbear version
- urlize support for quotes
- A loader was not found
- filters.map: apply filter to attribute ("mapattr")
- Template.render changelog is documented as using asyncio.run but does not
- no way to explicitly shutdown async generators HOT 1
- generate_async type annotation does not support `.aclose()`
- root_render_func not properly aclosed in Template.generate_async
- Jinja strips trailing newline
- Allow to customize some behaviors of Lexer, so that Extension instances get can the raw block begin and end info.
- Optional literal eval on native environments HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jinja.