Skip to content
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

Made modifications to reduce queries when using remote storage. #226

Closed
wants to merge 6 commits into from
Closed

Made modifications to reduce queries when using remote storage. #226

wants to merge 6 commits into from

Conversation

epicserve
Copy link

This should mostly fix issue #195. I also ran the tox test suite and all tests pass except for Python 2.5 tests. I mentioned that easy-thumbnails should drop 2.5 support in pull request #224.

Also, I'm not sure if another issue should be created but it would be nice if easy-thumbnails had an option to use Django's caching framework instead of the database.

  • Made a modification to the Thumbnailer class so it doesn't make a query to the source table if it's already been queried once before.
  • Updated the function generate_all_aliases so after all the thumbnails for all aliases have been created, it updates the modified time on all the thumbnails to match the modified time of the source file. This prevents the thumbnails getting recreated on first load.

- Added `PIP_INSECURE = 1` to all the Python 2.5 environments so packages would install.
- Changed the `py25` env so it uses the last version of Django that supports Python 2.5
- Changed the `py26` and `py27` envs so they use Django 1.5.1
- It should be noted that non of the environments that use Django 1.2.X pass anymore. This is most likely because of commit 6d5d9cc which added the widget `django.forms.widgets.ClearableFileInput` that was new in Django 1.3.X. Maybe easy-thumbnails should consider dropping support for Python 2.5 and Django 1.2.X.
- Made a modification to the Thumbnailer class so it doesn't make a query to the source table if it's already been queried once before.
- Updated the function generate_all_aliases so after all the thumbnails for all aliases have been created, it updates the modified time on all the thumbnails to match the modified time of the source file. This prevents the thumbnails getting recreated on first load.
@rofrankel
Copy link
Contributor

Thanks for the follow-up/sorry for the slow reply. I didn't get it figured out, using 1.5.1.

@epicserve
Copy link
Author

@rofrankel

Putting something like the following in your settings should resolve this issue for you ...

# HACK: This prevents getting the "ImproperlyConfigured: The SECRET_KEY setting must not be empty."
def get_easy_thumbnail_processors():
    from easy_thumbnails.conf import Settings as easy_thumbnails_defaults
    return easy_thumbnails_defaults.THUMBNAIL_PROCESSORS + (
        'wb_project.thumbnail_processors.whizzbang_processor',
    )
THUMBNAIL_PROCESSORS = get_easy_thumbnail_processors

Removed `if storage.exists(filename):` because when using a remote storage like S3 the storage backend downloads large amounts of XML, if you have a bucket with lots of objects. When saving several different thumbnails for just one file, the memory for my python process would grow to 2.75 GB.
@SmileyChris
Copy link
Owner

Most of this was pulled in indirectly in changes I made in 1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants