thadeusb / flask-cache

Cache extension for Flask
http://packages.python.org/Flask-Cache/
Other
700 stars 185 forks source link

Moves setting the app attribute to the _set_cache method #117

Open vicentealencar opened 9 years ago

vicentealencar commented 9 years ago

Initializing a Cache instance with a None app and setting it later via init_app causes the app attribute never to be set. This is fine for most cases, since the cache is being set to the app extension. However, it causes crashes when calling the Cache outside of a Flask context (e.g.: spawned threads).

I found this while updating a project I was working on from an old Flask-Cache version to the most up-to-date. Our app was crashing when it spawned gevent threads in order to load data in parallel.

Fuyukai commented 9 years ago

Hi there, I've merged this in my fork of the repository at https://github.com/SkierPGP/flask-cache